-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: add NewRequestWithContext #59473
Comments
Seems reasonable to me. |
Does this need to go to the proposal committee or should I just submit a CL? |
Change https://go.dev/cl/548355 mentions this issue: |
This does need to be approved by the proposal committee, since it's adding a new exported function. I think this change is reasonable, and support it. |
Based on the discussion above, this proposal seems like a likely accept. The proposal is to add func NewRequestWithContext(ctx context.Context, method, target string, body io.Reader) *http.Request that behaves like httptest.NewRequest except it also adds a context. |
No change in consensus, so accepted. 🎉 The proposal is to add func NewRequestWithContext(ctx context.Context, method, target string, body io.Reader) *http.Request that behaves like httptest.NewRequest except it also adds a context. |
This matches the net/http API. Updates #59473. Change-Id: I99917cef3ed42a0b4a2b39230b492be00da8bbfd Reviewed-on: https://go-review.googlesource.com/c/go/+/548355 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Damien Neil <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
This got implemented by @kevinburke in CL https://go-review.googlesource.com/c/go/+/548355 but it used "Updates #NNN" instead of "Fixes #NNN" so Github didn't auto-close the issue, hence I am closing it right now. Thank you Kevin! |
Recently the net/http package added NewRequestWithContext, which allows callers to pass in a context.Context without a second method call and/or copying the http.Request.
The proposal is to add the same API to httptest, so users don't need to think about it or wonder why httptest does not expose the same API as net/http for creating requests.
Updates #23544.
The text was updated successfully, but these errors were encountered: