aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/api/http/server.go
diff options
context:
space:
mode:
authorLewis Marshall <lewis@lmars.net>2017-07-25 17:51:26 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-07-25 17:51:26 +0800
commitf4841ff43dda9f41a47ec94b5a5356023eec59d4 (patch)
tree230bdce1fb090599bb4ed97c5aae416534335d65 /swarm/api/http/server.go
parent3a678a15c92e287c90eabab75463bbed97ba832c (diff)
downloadgo-tangerine-f4841ff43dda9f41a47ec94b5a5356023eec59d4.tar
go-tangerine-f4841ff43dda9f41a47ec94b5a5356023eec59d4.tar.gz
go-tangerine-f4841ff43dda9f41a47ec94b5a5356023eec59d4.tar.bz2
go-tangerine-f4841ff43dda9f41a47ec94b5a5356023eec59d4.tar.lz
go-tangerine-f4841ff43dda9f41a47ec94b5a5356023eec59d4.tar.xz
go-tangerine-f4841ff43dda9f41a47ec94b5a5356023eec59d4.tar.zst
go-tangerine-f4841ff43dda9f41a47ec94b5a5356023eec59d4.zip
swarm/api/http: redirect root manifest requests to include trailing slash (#14806)
Diffstat (limited to 'swarm/api/http/server.go')
-rw-r--r--swarm/api/http/server.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/swarm/api/http/server.go b/swarm/api/http/server.go
index 5f64f971b..b4032839a 100644
--- a/swarm/api/http/server.go
+++ b/swarm/api/http/server.go
@@ -522,6 +522,12 @@ func (s *Server) HandleGetList(w http.ResponseWriter, r *Request) {
// HandleGetFile handles a GET request to bzz://<manifest>/<path> and responds
// with the content of the file at <path> from the given <manifest>
func (s *Server) HandleGetFile(w http.ResponseWriter, r *Request) {
+ // ensure the root path has a trailing slash so that relative URLs work
+ if r.uri.Path == "" && !strings.HasSuffix(r.URL.Path, "/") {
+ http.Redirect(w, &r.Request, r.URL.Path+"/", http.StatusMovedPermanently)
+ return
+ }
+
key, err := s.api.Resolve(r.uri)
if err != nil {
s.Error(w, r, fmt.Errorf("error resolving %s: %s", r.uri.Addr, err))