You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With a real response, the Content-Type header will be set using http.DetectContentType
if it hasn't already been set explicitly. httptest.ResponseRecorder does not share this
behaviour.
I found this behaviour somewhat confusing - it took me a while to track down why the
ResponseRecorder headers didn't match the headers I was seeing with curl.
What does 'go version' print?
go version go1.3.3 linux/amd64
What steps reproduce the problem?
http://play.golang.org/p/mOjVsUQA-T
What happened?
The ResponseRecorder instance had no Content-Type header set.
What should have happened instead?
It should have been set to the content type detected from the response body.
The text was updated successfully, but these errors were encountered:
Can't really change it now (even if we wanted to) as it would break people's tests. So
probably just a documentation issue.
But even the net/http ResponseWriter contract doesn't say what the behavior is here, so
I think the httptest.Recorder is more faithful: it records exactly what you did. No
magic recording.
We should document on both sides.
Somewhat related: issue #8992 for omitting the Content-Type from handlers.
by alex.tomlins@digital.cabinet-office.gov.uk:
The text was updated successfully, but these errors were encountered: