Fix request path. Wasn't using proxy correctly
License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>
Hector Sanjuan committed
Oct 5, 2018 at 11:21 UTC
42a843d66b90fe9c9bd19913165e59aae8c33374
1 file changed
+3
-2
core/corehttp/proxy.go
+3
-2
@@ -26,7 +26,8 @@ func ProxyOption() ServeOption {
26
}
27
28
request.Host = "" // Let URL's Host take precedence.
29
- target, err := url.Parse(fmt.Sprintf("libp2p://%s/%s", parsedRequest.target, parsedRequest.httpPath))
29
+ request.URL.Path = parsedRequest.httpPath
30
+ target, err := url.Parse(fmt.Sprintf("libp2p://%s", parsedRequest.target))
31
if err != nil {
32
handleError(w, "Failed to parse url", err, 400)
33
return
@@ -57,7 +58,7 @@ func parseRequest(request *http.Request) (*proxyRequest, error) {
58
return nil, fmt.Errorf("Invalid request path '%s'", path)
59
}
60
60
- return &proxyRequest{split[3], protocol.ID(split[4]), "/" + split[5]}, nil
61
+ return &proxyRequest{split[3], protocol.ID(split[4]), split[5]}, nil
62
}
63
64
func handleError(w http.ResponseWriter, msg string, err error, code int) {