fako1024/httpc

Fix redirect behavior for 307/308 status codes

Closed this issue · 1 comments

els0r commented

The way RunWithContext is set up inside httpc, it prevents some important features which are available via NewRequestWithContext from net/http:

If body is of type *bytes.Buffer, *bytes.Reader, or *strings.Reader, the returned request's ContentLength is set to its exact value
(instead of -1), GetBody is populated (so 307 and 308 redirects can replay the body), and Body is set to NoBody if the
ContentLength
is 0.

This popped up testing github.com/els0r/goProbe trying to call global-query with goQuery, failing because the ingress in front of the global-query server redirected /_query to /_query/. httpc, or more specifically net/http wasn't following the request since the body isn't supplied to NewRequestWithContext.

@els0r Noice, thanks a lot! I've bumped httpc to v1.0.17 (after updating a couple of dependencies while at it), feel free to bump the version on goProbe at your convenience...