Skip to content
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

Nil request body with retry #4075

Merged
merged 1 commit into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion healthcheck/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (b *BackendConfig) newRequest(serverURL *url.URL) (*http.Request, error) {

u.Path += b.Path

return http.NewRequest(http.MethodGet, u.String(), nil)
return http.NewRequest(http.MethodGet, u.String(), http.NoBody)
}

// this function adds additional http headers and hostname to http.request
Expand Down
2 changes: 1 addition & 1 deletion middlewares/auth/forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func Forward(config *types.Forward, w http.ResponseWriter, r *http.Request, next
}
}

forwardReq, err := http.NewRequest(http.MethodGet, config.Address, nil)
forwardReq, err := http.NewRequest(http.MethodGet, config.Address, http.NoBody)
tracing.LogRequest(tracing.GetSpan(r), forwardReq)
if err != nil {
tracing.SetErrorAndDebugLog(r, "Error calling %s. Cause %s", config.Address, err)
Expand Down
2 changes: 1 addition & 1 deletion middlewares/errorpages/error_pages.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func newRequest(baseURL string) (*http.Request, error) {
return nil, fmt.Errorf("error pages: error when parse URL: %v", err)
}

req, err := http.NewRequest(http.MethodGet, u.String(), nil)
req, err := http.NewRequest(http.MethodGet, u.String(), http.NoBody)
if err != nil {
return nil, fmt.Errorf("error pages: error when create query: %v", err)
}
Expand Down
3 changes: 3 additions & 0 deletions middlewares/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ func (retry *Retry) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
// cf https://github.com/containous/traefik/issues/1008
if retry.attempts > 1 {
body := r.Body
if body == nil {
body = http.NoBody
}
defer body.Close()
r.Body = ioutil.NopCloser(body)
}
Expand Down