@cryptotaxi247 / kubo / commits / ac5cfc566

fixing bug 812

bbenshoof committed Feb 25, 2015 at 09:18 UTC ac5cfc566443172feec4abbc910e47088f657c94
2 files changed +30 -1
core/corehttp/redirect.go
+1 -1
@@ -9,7 +9,7 @@ import (
9 func RedirectOption(path string, redirect string) ServeOption {
10 handler := &redirectHandler{redirect}
11 return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) {
12 - mux.Handle("/"+path, handler)
12 + mux.Handle("/"+path+"/", handler)
13 return mux, nil
14 }
15 }
test/sharness/t0110-gateway.sh
+29
@@ -12,6 +12,8 @@ test_init_ipfs
12 test_config_ipfs_gateway_readonly "/ip4/0.0.0.0/tcp/5002"
13 test_launch_ipfs_daemon
14
15 +webui_hash="QmXdu7HWdV6CUaUabd9q2ZeA4iHZLVyDRj3Gi4dsJsWjbr"
16 +
17 # TODO check both 5001 and 5002.
18 # 5001 should have a readable gateway (part of the API)
19 # 5002 should have a readable gateway (using ipfs config Addresses.Gateway)
@@ -63,6 +65,33 @@ test_expect_success "GET invalid path errors" '
65 test_must_fail wget http://127.0.0.1:5002/12345
66 '
67
68 +
69 +test_expect_success "GET webui forwards" '
70 + curl -I http://127.0.0.1:5001/webui | head -c 18 > actual1
71 + curl -I http://127.0.0.1:5001/webui/ | head -c 18 > actual2
72 + echo "HTTP/1.1 302 Found" | head -c 18 > expected
73 + echo "HTTP/1.1 301 Moved Permanently" | head -c 18 > also_ok
74 + cat actual1
75 + cat actual2
76 + cat expected
77 + cat also_ok
78 + (test_cmp expected actual1 || test_cmp actual1 also_ok)&&
79 + (test_cmp expected actual2 || test_cmp actual2 also_ok)&&
80 + rm expected &&
81 + rm also_ok &&
82 + rm actual1 &&
83 + rm actual2
84 +'
85 +
86 +#TODO make following test work
87 +#test_expect_success "GET webui loads" '
88 +# curl http://127.0.0.1:5001/ipfs/$webui_hash | head -n 1 > actual1
89 +#
90 +# rm expected &&
91 +# rm actual1 &&
92 +# rm actual2
93 +#'
94 +
95 test_kill_ipfs_daemon
96
97 test_done