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: ResponseRecorder.Result comment gives incorrect guarantee about ResponseRecorder.Body non-nil-ness #26442

Closed
adam-p opened this issue Jul 18, 2018 · 2 comments
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@adam-p
Copy link
Contributor

adam-p commented Jul 18, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

1.10.3

Does this issue reproduce with the latest release?

Yes.

What did you do?

Compare the ResponseRecorder.Result documentation/comment...

// The Response.Body is guaranteed to be non-nil and Body.Read call is
// guaranteed to not return any error other than io.EOF.

...to actual behaviour:

if rw.Body != nil {
	res.Body = ioutil.NopCloser(bytes.NewReader(rw.Body.Bytes()))
}
...and then no case for when rw.Body _is_ nil...

It seems that guarantee doesn't apply if Response.Body was nil to begin with.

@jackxbritton
Copy link
Contributor

jackxbritton commented Jul 18, 2018

I'll take this one.

@gopherbot
Copy link

Change https://golang.org/cl/124875 mentions this issue: httptest: guarantee ResponseRecorder.Result returns a non-nil body

@FiloSottile FiloSottile added the NeedsFix The path to resolution is known, but the work has not been done. label Jul 19, 2018
@FiloSottile FiloSottile added this to the Go1.11 milestone Jul 19, 2018
@FiloSottile FiloSottile changed the title doc: net/http/httptest: ResponseRecorder.Result comment gives incorrect guarantee about ResponseRecorder.Body non-nil-ness net/http/httptest: ResponseRecorder.Result comment gives incorrect guarantee about ResponseRecorder.Body non-nil-ness Jul 19, 2018
@golang golang locked and limited conversation to collaborators Jul 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants