good morning!!!!

Skip to content
Snippets Groups Projects
Commit 5cd4430a authored by Felix Lange's avatar Felix Lange
Browse files

swarm/api/http: reject requests without content-length

parent 23420ff6
No related branches found
No related tags found
No related merge requests found
......@@ -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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment