-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
http: add QueryUnescape in HTTPPool.ServeHTTP #91
base: master
Are you sure you want to change the base?
Conversation
This is missing a bug (or description of the problem in the commit message), and is missing a test. And does this change break behavior of existing clients? Can this be incrementally rolled out safely? I think if we're changing the "protocol" like this, we should make it explicit and put something in the URL from the client to indicate that the peer "server" should unescape like this, whether that something is a new path component or header or query parameter. |
I find this change breaks behavior of existing clients. For example, a key "+myKey+" sent in raw format will be converted to " myKey ". How about adding a query parameter |
Sounds good. Or |
0f3cb5d
to
7b7eb1d
Compare
I add |
http.go
Outdated
@@ -138,19 +138,45 @@ func (p *HTTPPool) PickPeer(key string) (ProtoGetter, bool) { | |||
return nil, false | |||
} | |||
|
|||
func (p *HTTPPool) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |||
// Parse request. | |||
func (p *HTTPPool) parseRequest(r *http.Request) (string, string, bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use named result parameters here, otherwise (string, string, bool) is super confusing, especially without docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bradfitz Modified. Thanks for your review.
HTTPPool will inverse escaped path if query parameter contains "escaped=true". Add keys with char to be escaped in test.
7b7eb1d
to
e652685
Compare
Use url.QueryUnescape to inverse escaped group and key in path.