fix: handle Transfer-Encoding for make bucket

In case of make bucket, there is a chance of Transfer-Encoding is sent
where Content-Length is missing.  This patch fixes the problem by
checking whether Transfer-Encoding: chunked is set along with
Content-Length.
master
Bala.FA 9 years ago
parent 3a55d05eff
commit d79fcb1800
  1. 2
      bucket-handlers.go
  2. 10
      utils.go

@ -230,7 +230,7 @@ func (api CloudStorageAPI) PutBucketHandler(w http.ResponseWriter, req *http.Req
// if body of request is non-nil then check for validity of Content-Length // if body of request is non-nil then check for validity of Content-Length
if req.Body != nil { if req.Body != nil {
/// if Content-Length is unknown/missing, deny the request /// if Content-Length is unknown/missing, deny the request
if req.ContentLength == -1 { if req.ContentLength == -1 && !contains(req.TransferEncoding, "chunked") {
writeErrorResponse(w, req, MissingContentLength, req.URL.Path) writeErrorResponse(w, req, MissingContentLength, req.URL.Path)
return return
} }

@ -46,3 +46,13 @@ func isMaxObjectSize(size int64) bool {
} }
return false return false
} }
func contains(stringList []string, element string) bool {
for _, e := range stringList {
if e == element {
return true
}
}
return false
}

Loading…
Cancel
Save