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: Unclear if modifying http.Request.URL in ServeHTTP is legal. #18952
Comments
Unsure if ServeHTTP is allowed to modify req.URL.Path, related to golang/go#18952.
/cc @bradfitz |
Yeah, I suppose StripPrefix should follow the rules (which were written after StripPrefix was). Anybody want to send a CL? |
So you're confirming that modifying req.URL is considered against the contract. I wonder if gorilla/mux and other libraries currently do that or not. If they do, they'll need to be updated. I can send a CL if you want to help me understand the way you expect this resolved. Would we need to make a shallow copy of |
CL https://golang.org/cl/36483 mentions this issue. |
Use http.StripPrefix from Go 1.9, since it has the bug fixed. Related to golang/go#18952.
I'm reopening this because apparently there is code out there that will break as a result of creating a new Not that we necessarily need to revert, but someone needs to think about which state is worse. |
ping @bradfitz |
There used to be somewhat valid reasons to have Let's see how it goes with the beta and see if people are actually affected. But @quentinmit, if you know of concrete examples of such code, let me know and we can reconsider. But if this is just hypothetical, I'm inclined to wait and see. We already have code which modifies the passed-through *Request. This is just one more. |
See https://go-review.googlesource.com/c/go/+/36483/3/src/net/http/server.go, golang/go#18952 for more information on why this is necessary.
Go 1.9 is long since out, so the copy isn't needed anymore. This reverts a part of commit 4556ed9. Updates golang/go#18952.
As of https://golang.org/cl/21530 (/cc @bradfitz), which resolved #14940,
http.Handler
doc says aboutServeHTTP(http.ResponseWriter, *http.Request)
:Yet here's what
http.StripPrefix
does:Is modifying
http.Request.URL
not considered as modifyinghttp.Request
itself? If so, I believe the documentation needs to be more clear about that.Or is there a bug in
http.StripPrefix
?The text was updated successfully, but these errors were encountered: