mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-22 10:57:42 +08:00
[http_proxy_over_p2p] remove now superfluous test
License: MIT Signed-off-by: Chris Boddy <chris@boddy.im>
This commit is contained in:
parent
22f3b11621
commit
335bca2bb7
@ -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)
|
||||
|
||||
|
||||
@ -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(""))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user