diff options
author | Lewis Marshall <lewis@lmars.net> | 2017-04-07 06:22:22 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2017-04-07 06:22:22 +0800 |
commit | 71fdaa42386173da7bfa13f1728c394aeeb4eb01 (patch) | |
tree | 364a169f650982d3b2880c95e40e2c91cb27c86e /swarm/api/http/roundtripper_test.go | |
parent | 9aca9e6deb243b87cc75325be593a3b0c2f0a113 (diff) | |
download | dexon-71fdaa42386173da7bfa13f1728c394aeeb4eb01.tar dexon-71fdaa42386173da7bfa13f1728c394aeeb4eb01.tar.gz dexon-71fdaa42386173da7bfa13f1728c394aeeb4eb01.tar.bz2 dexon-71fdaa42386173da7bfa13f1728c394aeeb4eb01.tar.lz dexon-71fdaa42386173da7bfa13f1728c394aeeb4eb01.tar.xz dexon-71fdaa42386173da7bfa13f1728c394aeeb4eb01.tar.zst dexon-71fdaa42386173da7bfa13f1728c394aeeb4eb01.zip |
swarm/api: refactor and improve HTTP API (#3773)
This PR deprecates the file related RPC calls in favour of an improved HTTP API.
The main aim is to expose a simple to use API which can be consumed by thin
clients (e.g. curl and HTML forms) without the need for complex logic (e.g.
manipulating prefix trie manifests).
Diffstat (limited to 'swarm/api/http/roundtripper_test.go')
-rw-r--r-- | swarm/api/http/roundtripper_test.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/swarm/api/http/roundtripper_test.go b/swarm/api/http/roundtripper_test.go index fc74f5d3a..f99c4f35e 100644 --- a/swarm/api/http/roundtripper_test.go +++ b/swarm/api/http/roundtripper_test.go @@ -18,14 +18,14 @@ package http import ( "io/ioutil" + "net" "net/http" + "net/http/httptest" "strings" "testing" "time" ) -const port = "3222" - func TestRoundTripper(t *testing.T) { serveMux := http.NewServeMux() serveMux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -36,9 +36,12 @@ func TestRoundTripper(t *testing.T) { http.Error(w, "Method "+r.Method+" is not supported.", http.StatusMethodNotAllowed) } }) - go http.ListenAndServe(":"+port, serveMux) - rt := &RoundTripper{Port: port} + srv := httptest.NewServer(serveMux) + defer srv.Close() + + host, port, _ := net.SplitHostPort(srv.Listener.Addr().String()) + rt := &RoundTripper{Host: host, Port: port} trans := &http.Transport{} trans.RegisterProtocol("bzz", rt) client := &http.Client{Transport: trans} |