New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
r2.Request
should follow 307 on non-GET
#177
Comments
OK, I tracked down what is caused this, it is the absence of Applying the following updates to the script above diff --git a/main.go b/main.go
index 8b95934..80a972e 100644
--- a/main.go
+++ b/main.go
@@ -1,7 +1,11 @@
package main
import (
+ "bytes"
+ "encoding/json"
"fmt"
+ "io"
+ "io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
@@ -40,6 +44,10 @@ func main() {
fmt.Printf("body: %q\n\n%#v\n", string(body), res)
data := map[string]string{"token": "foo"}
+ bodyBytes, err := json.Marshal(data)
+ if err != nil {
+ panic(err)
+ }
// Do a POST.
fmt.Println("--- Doing a POST ---")
opts = []r2.Option{
@@ -51,6 +59,9 @@ func main() {
r2.OptJSONBody(data),
}
r := r2.New("", opts...)
+ r.Request.GetBody = func() (io.ReadCloser, error) {
+ return ioutil.NopCloser(bytes.NewReader(bodyBytes)), nil
+ }
body, res, err = r.Bytes()
if err != nil {
panic(err) we get
|
From the req.GetBody = func() (io.ReadCloser, error) {
r := bytes.NewReader(buf)
return ioutil.NopCloser(r), nil
} |
This was fixed by #178. |
See #175 for context. To test
which produces
The text was updated successfully, but these errors were encountered: