-
Notifications
You must be signed in to change notification settings - Fork 18k
net/http: clarify that (*Request).WithContext affects the Response too #26101
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
Comments
It might be worthwhile to be more explicit on the details before deciding on the best documentation to balance conciseness and accuracy. Somewhat related: #23262 |
Is your Actual note how it actually behaves? I'm not sure of the precise actual behavior, and I'm also unsure of the correct language to use to be brief and accurate regarding the relationship between a context, request, and response; so I'm going to leave it to the Go authors or a more-ambitious-than-me contributor to take on a CL for this doc update. |
That sounds fine to me to be the new documentation. Re the exclusions, the exclusion is any time there is no body or expected body correct? |
@bradfitz care to weigh in on the docs change being discussed here? |
Change https://golang.org/cl/129155 mentions this issue: |
What version of Go are you using (
go version
)?https://golang.org/pkg/net/http/#Request.Context
Does this issue reproduce with the latest release?
Same docs on https://tip.golang.org/pkg/net/http/#Request.Context
What did you do?
I read:
I thought the context only affected its associated
Request
, and that theResponse
returned fromClient.Do(Request)
would be unaffected by the context.I searched the net/http Godoc for any mentions of Context relating to a Response but didn't find anything.
Finally, after a long discussion with coworkers, we came up with a manual test case demonstrating that the request context does in fact affect the response:
We would have saved a lot of time today if the doc said something more like "For outgoing client requests and their corresponding responses, the context controls cancelation."
The text was updated successfully, but these errors were encountered: