net/http: StripPrefix creates a new request, confusing middleware #20948
Labels
Milestone
Comments
\cc @bradfitz |
@quentinmit had brought this up as a concern at #18952 (comment) I'm still inclined to fix the affected code, though. Relying on |
Perhaps a release note? |
Agree with Brad. It's fine to add a release note warning, but we've been making copies of Requests since at least Go 1.8's WithContext. Middleware should also be using context at this point I would imagine. |
CL https://golang.org/cl/48190 mentions this issue. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
As of http://golang.org/cl/36483, StripPrefix creates a new request with the modified URL rather than modifying the existing request. That means that the identify of the request object can change between different handlers. If an earlier handler used a map[*http.Request], and then a later handler tries to read that value, it won't find it. This broke one important Google-internal use case, and a Github search shows a lot of such maps, so it may be worth addressing. I don't know how given the conflicting requirement to not modify the request.
The text was updated successfully, but these errors were encountered: