tests: create new request instead of updating old

This commit is contained in:
Steffen Vogel 2021-01-18 20:40:08 +01:00
parent da6515dddd
commit 5627e80b27

View file

@ -183,12 +183,17 @@ func handleRedirect(w *httptest.ResponseRecorder, req *http.Request) (int, *byte
w.Code == http.StatusPermanentRedirect {
// Follow external redirect
var err error
req.URL, err = w.Result().Location()
redirURL, err := w.Result().Location()
if err != nil {
return 0, nil, fmt.Errorf("Invalid location header")
}
// TODO: resend orginal request body
req, err := http.NewRequest(req.Method, redirURL.String(), nil)
if err != nil {
return 0, nil, fmt.Errorf("Failed to create new request: %v", err)
}
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {