From 335bca2bb7da738d329e25fd0cf1f7b705fcf52a Mon Sep 17 00:00:00 2001 From: Chris Boddy Date: Tue, 2 Oct 2018 09:51:51 +0100 Subject: [PATCH] [http_proxy_over_p2p] remove now superfluous test License: MIT Signed-off-by: Chris Boddy --- core/corehttp/proxy.go | 3 +++ core/corehttp/proxy_test.go | 12 ------------ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/core/corehttp/proxy.go b/core/corehttp/proxy.go index 8e236d155..4683bc2ca 100644 --- a/core/corehttp/proxy.go +++ b/core/corehttp/proxy.go @@ -5,6 +5,7 @@ import ( "fmt" "net" "net/http" + //"net/http/httputil" "strings" core "github.com/ipfs/go-ipfs/core" @@ -13,6 +14,7 @@ import ( peer "gx/ipfs/QmbNepETomvmXfz1X5pHNFD2QuPqnqi47dTd94QJWSorQ3/go-libp2p-peer" ) +// This adds an endpoint for proxying a request to another ipfs peer func ProxyOption() ServeOption { return func(ipfsNode *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.HandleFunc("/proxy/http/", func(w http.ResponseWriter, request *http.Request) { @@ -31,6 +33,7 @@ func ProxyOption() ServeOption { return } + //httputil.ReverseProxy( // send request to peer proxyReq, err := http.NewRequest(request.Method, parsedRequest.httpPath, request.Body) diff --git a/core/corehttp/proxy_test.go b/core/corehttp/proxy_test.go index e5b085895..e3279317c 100644 --- a/core/corehttp/proxy_test.go +++ b/core/corehttp/proxy_test.go @@ -20,18 +20,6 @@ func TestParseRequest(t *testing.T) { assert.True(parsed.target.Pretty() == "QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT", t, "proxy request peer-id") } -func TestParseRequestInvalidProtocol(t *testing.T) { - url := "http://localhost:5001/proxy/invalid/QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT/test-name/path/to/index.txt" - req, _ := http.NewRequest("GET", url, strings.NewReader("")) - - _, err := parseRequest(req) - if err == nil { - t.Fail() - } - - assert.True(err.Error() == "Invalid proxy request protocol 'invalid'", t, "fails with invalid proxy") -} - func TestParseRequestInvalidPath(t *testing.T) { url := "http://localhost:5001/proxy/http/foobar" req, _ := http.NewRequest("GET", url, strings.NewReader(""))