TUN-2279: Revert path encoding fix

This reverts commit f6c7f8a96c.
This commit is contained in:
Areg Harutyunyan
2019-09-05 22:03:31 -05:00
parent dc730615f2
commit a10785a701
2 changed files with 9 additions and 110 deletions

View File

@@ -45,13 +45,16 @@ func H2RequestHeadersToH1Request(h2 []h2mux.Header, h1 *http.Request) error {
// Otherwise the host header will be based on the origin URL
h1.Host = header.Value
case ":path":
// Separate the path and the (optional) query from each other
chunks := strings.SplitN(header.Value, "?", 2)
h1.URL.Path = chunks[0]
if len(chunks) > 1 {
h1.URL.RawQuery = chunks[1]
u, err := url.Parse(header.Value)
if err != nil {
return fmt.Errorf("unparseable path")
}
resolved := h1.URL.ResolveReference(u)
// prevent escaping base URL
if !strings.HasPrefix(resolved.String(), h1.URL.String()) {
return fmt.Errorf("invalid path")
}
h1.URL = resolved
case "content-length":
contentLength, err := strconv.ParseInt(header.Value, 10, 64)
if err != nil {