Skip to content

Commit 008d250

Browse files
acudnonsense
authored andcommitted
swarm/api/http: fix bzz-hash to return ens resolved hash directly (#19594)
1 parent cf38a3d commit 008d250

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

‎swarm/api/http/server.go‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,6 @@ func (s *Server) HandleGet(w http.ResponseWriter, r *http.Request) {
669669

670670
// if path is set, interpret <key> as a manifest and return the
671671
// raw entry at the given path
672-
673672
etag := common.Bytes2Hex(addr)
674673
noneMatchEtag := r.Header.Get("If-None-Match")
675674
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) {
680679
}
681680
}
682681

683-
// check the root chunk exists by retrieving the file's size
684-
reader, isEncrypted := s.api.Retrieve(r.Context(), addr)
685-
if _, err := reader.Size(r.Context(), nil); err != nil {
686-
getFail.Inc(1)
687-
respondError(w, r, fmt.Sprintf("root chunk not found %s: %s", addr, err), http.StatusNotFound)
688-
return
689-
}
690-
691-
w.Header().Set("X-Decrypted", fmt.Sprintf("%v", isEncrypted))
692-
693682
switch {
694683
case uri.Raw():
684+
// check the root chunk exists by retrieving the file's size
685+
reader, isEncrypted := s.api.Retrieve(r.Context(), addr)
686+
if _, err := reader.Size(r.Context(), nil); err != nil {
687+
getFail.Inc(1)
688+
respondError(w, r, fmt.Sprintf("root chunk not found %s: %s", addr, err), http.StatusNotFound)
689+
return
690+
}
691+
692+
w.Header().Set("X-Decrypted", fmt.Sprintf("%v", isEncrypted))
693+
695694
// allow the request to overwrite the content type using a query
696695
// parameter
697696
if typ := r.URL.Query().Get("content_type"); typ != "" {
@@ -703,6 +702,7 @@ func (s *Server) HandleGet(w http.ResponseWriter, r *http.Request) {
703702
w.WriteHeader(http.StatusOK)
704703
fmt.Fprint(w, addr)
705704
}
705+
706706
}
707707

708708
// HandleGetList handles a GET request to bzz-list:/<manifest>/<path> and returns

0 commit comments

Comments
 (0)