Use request context in p2p stream http proxy
License: MIT Signed-off-by: Ian Preston <ianopolous@protonmail.com>
Dr Ian Preston committed
Oct 3, 2018 at 19:31 UTC
6e24fc609a7c2595f969dcf9e5a70a6d87a5ddfe
1 file changed
+3
-3
core/corehttp/proxy.go
+3
-3
@@ -3,8 +3,8 @@ package corehttp
3
import (
4
"bufio"
5
"fmt"
6
- "net"
6
"io"
7
+ "net"
8
"net/http"
9
"net/http/httputil"
10
"strings"
@@ -28,7 +28,7 @@ func ProxyOption() ServeOption {
28
}
29
30
// open connect to peer
31
- stream, err := ipfsNode.P2P.PeerHost.NewStream(ipfsNode.Context(), parsedRequest.target, protocol.ID("/x/"+parsedRequest.name))
31
+ stream, err := ipfsNode.P2P.PeerHost.NewStream(request.Context(), parsedRequest.target, protocol.ID("/x/"+parsedRequest.name))
32
if err != nil {
33
msg := fmt.Sprintf("Failed to open stream '%v' to target peer '%v'", parsedRequest.name, parsedRequest.target)
34
handleError(w, msg, err, 500)
@@ -121,7 +121,7 @@ func (rt *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
121
122
resp.Body = &respBody{
123
ReadCloser: resp.Body,
124
- stream: rt.stream,
124
+ stream: rt.stream,
125
}
126
127
return resp, nil