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: allow removal of Content-Type and Connection headers in response #5950
Labels
Comments
You might consider hijacking the connection and writing the HTTP response yourself, although that would defeat keepalive. http://golang.org/pkg/net/http/#Hijacker Would you mind filing a separate issue about the bug? |
If I understand correctly, if I hijack the connection, then I need to take care of composing and emitted well-formed HTTP, no? I can't just use net/http's Request.Write (because it'll emit these headers), but the implementation of Request.Write relies on a good deal of unexported net/http, which means borrowing it will be non-trivial. I suppose I could do something ugly like inspect and modify the output of Request.Write, but that feels ugly and fragile. It is definitely a minor issue, but it seems reasonable for other auto-added headers to behave like the Date header in this regard. Evidence that the Date header behavior is right is that I didn't consult documentation -- I just tried it, and it worked exactly as I expected. Filed issue https://golang.org/issue/5953 about the double Content-Type headers. |
Dave: Good point, thanks. Connection: close is being returned for HTTP/1.0 requests. Filed https://golang.org/issue/5955 for that. |
Confirmed: http://play.golang.org/p/zYXrsJVDDW |
I'm pretty sure I meant Request.Write... I used it in my example code. I'm going to mark this issue as WontFix because it's extremely rare that someone should not want to write a Content-Type header, and the Hijacker provides a means of doing so. Happy for others to argue otherwise. Status changed to WontFix. |
As a side effect of fixing https://golang.org/issue/5953, setting header["Content-Type"] = nil now does what I originally expected. Given that there's a separate issue filed about the Connection header, I'd say this can now be closed as fixed. :) |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: