aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/api
diff options
context:
space:
mode:
authorElad <theman@elad.im>2019-05-29 06:16:09 +0800
committerAnton Evangelatov <anton.evangelatov@gmail.com>2019-05-29 06:16:09 +0800
commit008d250e3c57e1b8a350c8049fe4af71cf26a7e9 (patch)
tree8c237880eb479f11d2b6609eccbb2913b0f15a60 /swarm/api
parentcf38a3dc654adacf23e6b3bc4f74d629d19bd19f (diff)
downloadgo-tangerine-008d250e3c57e1b8a350c8049fe4af71cf26a7e9.tar
go-tangerine-008d250e3c57e1b8a350c8049fe4af71cf26a7e9.tar.gz
go-tangerine-008d250e3c57e1b8a350c8049fe4af71cf26a7e9.tar.bz2
go-tangerine-008d250e3c57e1b8a350c8049fe4af71cf26a7e9.tar.lz
go-tangerine-008d250e3c57e1b8a350c8049fe4af71cf26a7e9.tar.xz
go-tangerine-008d250e3c57e1b8a350c8049fe4af71cf26a7e9.tar.zst
go-tangerine-008d250e3c57e1b8a350c8049fe4af71cf26a7e9.zip
swarm/api/http: fix bzz-hash to return ens resolved hash directly (#19594)
Diffstat (limited to 'swarm/api')
-rw-r--r--swarm/api/http/server.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/swarm/api/http/server.go b/swarm/api/http/server.go
index a336bd82f..88f2e4db9 100644
--- a/swarm/api/http/server.go
+++ b/swarm/api/http/server.go
@@ -669,7 +669,6 @@ func (s *Server) HandleGet(w http.ResponseWriter, r *http.Request) {
// if path is set, interpret <key> as a manifest and return the
// raw entry at the given path
-
etag := common.Bytes2Hex(addr)
noneMatchEtag := r.Header.Get("If-None-Match")
w.Header().Set("ETag", fmt.Sprintf("%q", etag)) // set etag to manifest key or raw entry key.
@@ -680,18 +679,18 @@ func (s *Server) HandleGet(w http.ResponseWriter, r *http.Request) {
}
}
- // check the root chunk exists by retrieving the file's size
- reader, isEncrypted := s.api.Retrieve(r.Context(), addr)
- if _, err := reader.Size(r.Context(), nil); err != nil {
- getFail.Inc(1)
- respondError(w, r, fmt.Sprintf("root chunk not found %s: %s", addr, err), http.StatusNotFound)
- return
- }
-
- w.Header().Set("X-Decrypted", fmt.Sprintf("%v", isEncrypted))
-
switch {
case uri.Raw():
+ // check the root chunk exists by retrieving the file's size
+ reader, isEncrypted := s.api.Retrieve(r.Context(), addr)
+ if _, err := reader.Size(r.Context(), nil); err != nil {
+ getFail.Inc(1)
+ respondError(w, r, fmt.Sprintf("root chunk not found %s: %s", addr, err), http.StatusNotFound)
+ return
+ }
+
+ w.Header().Set("X-Decrypted", fmt.Sprintf("%v", isEncrypted))
+
// allow the request to overwrite the content type using a query
// parameter
if typ := r.URL.Query().Get("content_type"); typ != "" {
@@ -703,6 +702,7 @@ func (s *Server) HandleGet(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
fmt.Fprint(w, addr)
}
+
}
// HandleGetList handles a GET request to bzz-list:/<manifest>/<path> and returns