Skip to content

Commit

Permalink
DoRedirects should follow DisablePathNormalizing
Browse files Browse the repository at this point in the history
DoRedirects was not using DisablePathNormalizing for the initial request
like the other Do function.

This change is not completely backwards compatible, but I can't imagine
a real world scenario in which this was the desired behaviour.
  • Loading branch information
erikdubbelboer committed Jan 26, 2025
1 parent 195155e commit 6371638
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ func DoDeadline(req *Request, resp *Response, deadline time.Time) error {
// It is recommended obtaining req and resp via AcquireRequest
// and AcquireResponse in performance-critical code.
func DoRedirects(req *Request, resp *Response, maxRedirectsCount int) error {
if defaultClient.DisablePathNormalizing {
req.URI().DisablePathNormalizing = true
}
_, _, err := doRequestFollowRedirects(req, resp, req.URI().String(), maxRedirectsCount, &defaultClient)
return err
}
Expand Down Expand Up @@ -461,6 +464,9 @@ func (c *Client) DoDeadline(req *Request, resp *Response, deadline time.Time) er
// It is recommended obtaining req and resp via AcquireRequest
// and AcquireResponse in performance-critical code.
func (c *Client) DoRedirects(req *Request, resp *Response, maxRedirectsCount int) error {
if c.DisablePathNormalizing {
req.URI().DisablePathNormalizing = true
}
_, _, err := doRequestFollowRedirects(req, resp, req.URI().String(), maxRedirectsCount, c)
return err
}
Expand Down Expand Up @@ -1317,6 +1323,9 @@ func (c *HostClient) DoDeadline(req *Request, resp *Response, deadline time.Time
// It is recommended obtaining req and resp via AcquireRequest
// and AcquireResponse in performance-critical code.
func (c *HostClient) DoRedirects(req *Request, resp *Response, maxRedirectsCount int) error {
if c.DisablePathNormalizing {
req.URI().DisablePathNormalizing = true
}
_, _, err := doRequestFollowRedirects(req, resp, req.URI().String(), maxRedirectsCount, c)
return err
}
Expand Down

0 comments on commit 6371638

Please sign in to comment.