From e030b2153a17d80f8571da9b92ee7f3052452d76 Mon Sep 17 00:00:00 2001 From: "Daniel A. Nagy" Date: Tue, 12 May 2015 21:51:34 +0200 Subject: [PATCH] Proper status handling for range requests. --- bzz/httpaccess.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/bzz/httpaccess.go b/bzz/httpaccess.go index c25aed60a9..1bf941333d 100644 --- a/bzz/httpaccess.go +++ b/bzz/httpaccess.go @@ -10,7 +10,6 @@ import ( "io" "net/http" "regexp" - "strconv" "sync" "time" ) @@ -174,10 +173,6 @@ func handler(w http.ResponseWriter, r *http.Request, dpa *DPA) { // content type defaults to manifest entry.ContentType = manifestType } - if entry.Status == 0 { - // status defaults to 200 - entry.Status = 200 - } pathLen := len(entry.Path) if len(path) >= pathLen && path[:pathLen] == entry.Path && prefix <= pathLen { dpaLogger.Debugf("Swarm: \"%s\" matches \"%s\".", path, entry.Path) @@ -195,8 +190,9 @@ func handler(w http.ResponseWriter, r *http.Request, dpa *DPA) { reader := dpa.Retrieve(key) w.Header().Set("Content-Type", mimeType) dpaLogger.Debugf("Swarm: HTTP Status %d", status) - w.Header().Set("Content-Length", strconv.FormatInt(reader.Size(), 10)) - w.WriteHeader(int(status)) + if status > 0 { + w.WriteHeader(int(status)) + } dpaLogger.Debugf("Swarm: Reading %d bytes.", reader.Size()) http.ServeContent(w, r, name, time.Unix(0, 0), reader) dpaLogger.Debugf("Swarm: Served %s as %s.", mimeType, uri)