Open frojasg opened 7 years ago
Interesting. I hadn't seen that note, nor have we seen adverse effects of doing so.
From here https://codereview.appspot.com/5284041/patch/1002/4, it looks it internally does mutate the request (though it undos it as well). So while I think it's meant to serve as a future warning, it should be ok given the current implementation.
Thank you!. Feel free to close this issue if you want 😄
I think this thread is relevant https://groups.google.com/forum/#!searchin/golang- nuts/RoundTripper%7Csort:relevance/golang-nuts/U4FPkQKcAzM/xPireKYNvowJ
The RoundTripper simply does not own the request, nor the header.
Yeah I think that's the key part. We can certainly improve the example to make it "proper" by copying the request, etc, but I think the act of sneaking in data via the request header should be ok.
One thing we could do is make chain.Request()
return a copy of the request. Or add some convencience functions for it.
Hello, a year late but as the oauth2 library modify the request (by copying the request), the train library should handle request cancellation as the request can be changed. Indeed, the sub roundtripper can create a new request based on the top one. But if the top one is cancelled, the new one must be too. Maybe it can be a helper for roundtripper but this is one purpose of chaining roundtripper, altering the requests (ie: to do auth layer)
Hi,
The RoundTripper documentation says:
The example in the README.md is mutating the request which goes against the library documentation.
If you modify a request inside an interceptor, wouldn't it lead to unexpected behaviors?
I tried to dig a little bit deeper why that comment was there, but I couldn't find an answer. This CL is when the comment was introduced to solve this issue, but it doesn't explain why :(.
P.S.: I loved this project, it's a pretty cool idea.