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

net/http: Client drops all headers on redirect #5782

Closed
gopherbot opened this issue Jun 26, 2013 · 1 comment
Closed

net/http: Client drops all headers on redirect #5782

gopherbot opened this issue Jun 26, 2013 · 1 comment

Comments

@gopherbot
Copy link

by robryk:

When the current client follows a redirect, all subsequent requests are sent without any
of the headers sent on the initial request. The following program demonstrates this
behaviour:

http://play.golang.org/p/AExnEZNwv8

The header which gets printed on stdout is empty; I'd expect it to be equal to
"bytes=0-1", the value set in the original request.

This is counterintuitive and makes the Request.Header useless if a redirect can occur.
It seems that one must either make a custom transport wrapper that adds headers and
create a client on top of that, or use an undocumented feature of CheckRedirect, namely
that the request passed is going to be actually sent, so it can modify it before that.

I'm not sure what resolution I'd expect. My main problem is that this behaviour confused
me, and I can't see an elegant way of setting eg. a Range header on subsequent requests
-- creating a new transport wrapper for every request seems weird, even if it's mostly
cost-free.
@rsc
Copy link
Contributor

rsc commented Jun 26, 2013

Comment 1:

Status changed to Duplicate.

Merged into issue #4800.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants