Skip to content

Commit

Permalink
Use request context in p2p stream http proxy
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Ian Preston <ianopolous@protonmail.com>
  • Loading branch information
ianopolous committed Oct 3, 2018
1 parent fe6ba82 commit 2fd1c26
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/corehttp/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package corehttp
import (
"bufio"
"fmt"
"net"
"io"
"net"
"net/http"
"net/http/httputil"
"strings"
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2fd1c26

Please sign in to comment.