From 2fd1c2671892c82e2cd9e1610ef85112efcad34d Mon Sep 17 00:00:00 2001 From: Dr Ian Preston <ianopolous@protonmail.com> Date: Wed, 3 Oct 2018 19:31:40 +0100 Subject: [PATCH] Use request context in p2p stream http proxy License: MIT Signed-off-by: Ian Preston <ianopolous@protonmail.com> --- core/corehttp/proxy.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/corehttp/proxy.go b/core/corehttp/proxy.go index 70a836ae604..b92cb341d76 100644 --- a/core/corehttp/proxy.go +++ b/core/corehttp/proxy.go @@ -3,8 +3,8 @@ package corehttp import ( "bufio" "fmt" - "net" "io" + "net" "net/http" "net/http/httputil" "strings" @@ -28,7 +28,7 @@ func ProxyOption() ServeOption { } // open connect to peer - stream, err := ipfsNode.P2P.PeerHost.NewStream(ipfsNode.Context(), parsedRequest.target, protocol.ID("/x/"+parsedRequest.name)) + stream, err := ipfsNode.P2P.PeerHost.NewStream(request.Context(), parsedRequest.target, protocol.ID("/x/"+parsedRequest.name)) if err != nil { msg := fmt.Sprintf("Failed to open stream '%v' to target peer '%v'", parsedRequest.name, parsedRequest.target) handleError(w, msg, err, 500) @@ -121,7 +121,7 @@ func (rt *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) { resp.Body = &respBody{ ReadCloser: resp.Body, - stream: rt.stream, + stream: rt.stream, } return resp, nil