Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
net/http: Client drops all headers on redirect #5782
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.
This issue was closed.