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/httptrace: Provide direction in the documentation for ClientTrace on safety of request mutations #39153

thesilentg opened this issue May 20, 2020 · 2 comments


Copy link

@thesilentg thesilentg commented May 20, 2020

The documentation for ClientTrace provides no guidance on if it is safe to modify the request from within any of the trace functions. It mentions that the functions within ClientTrace may be called concurrently, but does not comment on if these functions are permitted to modify the request. In contrast, the documentation for RoundTripper explicitly calls out the expected behavior:

    // RoundTrip should not modify the request, except for
    // consuming and closing the Request's Body. RoundTrip may
    // read fields of the request in a separate goroutine. Callers
    // should not mutate or reuse the request until the Response's
    // Body has been closed.

This concern was originally raised when attempting to use GotConn to modify the request Header to add the amount of time remaining until the request's context deadline, for use in distributed tracing. I would like to be able to modify certain properties in the request (Headers, Cookies, ...) in response to ClientTrace data, but need to understand if that behavior will continue to be supported.

This issue has two components:

  1. Provide guidance on if the functions within ClientTrace are permitted to modify the request
  2. If the functions within ClientTrace are permitted to modify the request, promise this expectation will continue in the future by updating the documentation to reflect this
@cagedmantis cagedmantis added this to the Backlog milestone May 21, 2020
Copy link

@cagedmantis cagedmantis commented May 21, 2020

Copy link

@thesilentg thesilentg commented Jun 15, 2020

@cagedmantis Hi Carlos, just wanted to check in and see if there was anyone else you think would be able to help answer this. It's been about a month at this point, and even just getting general directional guidance with regards to mutability would be helpful. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.