Skip to content

Commit

Permalink
Nil request body with retry
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored and traefiker committed Oct 23, 2018
1 parent 37d8e32 commit 3f044c4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
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

0 comments on commit 3f044c4

Please sign in to comment.