[http_proxy_over_p2p] remove now superfluous test
License: MIT Signed-off-by: Chris Boddy <chris@boddy.im>
Chris Boddy committed
Oct 2, 2018 at 09:51 UTC
335bca2bb7da738d329e25fd0cf1f7b705fcf52a
2 files changed
+3
-12
core/corehttp/proxy.go
+3
@@ -5,6 +5,7 @@ import (
5
"fmt"
6
"net"
7
"net/http"
8
+ //"net/http/httputil"
9
"strings"
10
11
core "github.com/ipfs/go-ipfs/core"
@@ -13,6 +14,7 @@ import (
14
peer "gx/ipfs/QmbNepETomvmXfz1X5pHNFD2QuPqnqi47dTd94QJWSorQ3/go-libp2p-peer"
15
)
16
17
+// This adds an endpoint for proxying a request to another ipfs peer
18
func ProxyOption() ServeOption {
19
return func(ipfsNode *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
20
mux.HandleFunc("/proxy/http/", func(w http.ResponseWriter, request *http.Request) {
@@ -31,6 +33,7 @@ func ProxyOption() ServeOption {
33
return
34
}
35
36
+ //httputil.ReverseProxy(
37
// send request to peer
38
proxyReq, err := http.NewRequest(request.Method, parsedRequest.httpPath, request.Body)
39
core/corehttp/proxy_test.go
-12
@@ -20,18 +20,6 @@ func TestParseRequest(t *testing.T) {
20
assert.True(parsed.target.Pretty() == "QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT", t, "proxy request peer-id")
21
}
22
23
-func TestParseRequestInvalidProtocol(t *testing.T) {
24
- url := "http://localhost:5001/proxy/invalid/QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT/test-name/path/to/index.txt"
25
- req, _ := http.NewRequest("GET", url, strings.NewReader(""))
26
-
27
- _, err := parseRequest(req)
28
- if err == nil {
29
- t.Fail()
30
- }
31
-
32
- assert.True(err.Error() == "Invalid proxy request protocol 'invalid'", t, "fails with invalid proxy")
33
-}
34
-
23
func TestParseRequestInvalidPath(t *testing.T) {
24
url := "http://localhost:5001/proxy/http/foobar"
25
req, _ := http.NewRequest("GET", url, strings.NewReader(""))