Skip to content

Commit

Permalink
http: add QueryUnescape in HTTPPool.ServeHTTP
Browse files Browse the repository at this point in the history
Use url.QueryUnescape to inverse escaped group and key in path.
  • Loading branch information
lorneli committed Nov 6, 2017
1 parent 84a468c commit 0f3cb5d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,16 @@ func (p *HTTPPool) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http.Error(w, "bad request", http.StatusBadRequest)
return
}
groupName := parts[0]
key := parts[1]
groupName, err := url.QueryUnescape(parts[0])
if err != nil {
http.Error(w, "bad request", http.StatusBadRequest)
return
}
key, err := url.QueryUnescape(parts[1])
if err != nil {
http.Error(w, "bad request", http.StatusBadRequest)
return
}

// Fetch the value for this group/key.
group := GetGroup(groupName)
Expand All @@ -164,7 +172,7 @@ func (p *HTTPPool) ServeHTTP(w http.ResponseWriter, r *http.Request) {

group.Stats.ServerRequests.Add(1)
var value []byte
err := group.Get(ctx, key, AllocatingByteSliceSink(&value))
err = group.Get(ctx, key, AllocatingByteSliceSink(&value))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
Expand Down

0 comments on commit 0f3cb5d

Please sign in to comment.