aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-11-11 04:14:17 +0800
committerFelix Lange <fjl@twurst.com>2016-11-11 07:15:21 +0800
commit5cd4430a8db82727b6690776302a50a8b80b610d (patch)
treee5fa5b531a5e41b6c0d7444c560637bde48b929f
parent23420ff67a1fb4a8d47a88708cb258172b5f435a (diff)
downloaddexon-5cd4430a8db82727b6690776302a50a8b80b610d.tar.gz
dexon-5cd4430a8db82727b6690776302a50a8b80b610d.tar.zst
dexon-5cd4430a8db82727b6690776302a50a8b80b610d.zip
swarm/api/http: reject requests without content-length
-rw-r--r--swarm/api/http/server.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/swarm/api/http/server.go b/swarm/api/http/server.go
index a35672687..9be60ef94 100644
--- a/swarm/api/http/server.go
+++ b/swarm/api/http/server.go
@@ -115,7 +115,11 @@ func handler(w http.ResponseWriter, r *http.Request, a *api.Api) {
switch {
case r.Method == "POST" || r.Method == "PUT":
- key, err := a.Store(r.Body, r.ContentLength, nil)
+ if r.Header.Get("content-length") == "" {
+ http.Error(w, "Missing Content-Length header in request.", http.StatusBadRequest)
+ return
+ }
+ key, err := a.Store(io.LimitReader(r.Body, r.ContentLength), r.ContentLength, nil)
if err == nil {
glog.V(logger.Debug).Infof("Content for %v stored", key.Log())
} else {