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/httptest: NewRecorder does not initialize Code to 200 #4188

Closed
gopherbot opened this issue Oct 3, 2012 · 4 comments
Closed

net/http/httptest: NewRecorder does not initialize Code to 200 #4188

gopherbot opened this issue Oct 3, 2012 · 4 comments
Milestone

Comments

@gopherbot
Copy link

by Jens.Alfke:

httptest.Recorder does not mimic the behavior of the real HTTP package when the handler
function does not explicitly call r.WriteHeader or r.Write. The real HTTP server will
return a status code of 200; but Recorder.Code will be 0.

For example with this no-op handler:

func myHandler(r http.ResponseWriter, rq *http.Request) {
}

Used in an actual server, the handler will always result in a status of 200.
But if called directly with an httptest.Recorder as the first parameter, the recorder's
Code will end up as 0, not 200.
@rsc
Copy link
Contributor

rsc commented Oct 6, 2012

Comment 1:

Labels changed: added priority-later, removed priority-triage.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Oct 6, 2012

Comment 2:

Labels changed: added go1.1.

@bradfitz
Copy link
Contributor

bradfitz commented Oct 6, 2012

Comment 3:

http://golang.org/cl/6613062

Owner changed to @bradfitz.

@bradfitz
Copy link
Contributor

bradfitz commented Oct 7, 2012

Comment 4:

This issue was closed by revision 13576e3.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@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

3 participants