[#450] Fix getPutPayloadSize

If X-Amz-Decoded-Content-Length explicitly set use it even if value is 0

Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
Denis Kirillov 2024-10-03 14:23:06 +03:00
parent 03481274f0
commit 346243b159
2 changed files with 69 additions and 9 deletions

View file

@ -91,17 +91,13 @@ func (h *handler) getPutPayloadSize(r *http.Request) uint64 {
decodeContentSize := r.Header.Get(api.AmzDecodedContentLength)
decodedSize, err := strconv.Atoi(decodeContentSize)
if err != nil {
decodedSize = 0
if r.ContentLength >= 0 {
return uint64(r.ContentLength)
}
return 0
}
var size uint64
if decodedSize > 0 {
size = uint64(decodedSize)
} else if r.ContentLength > 0 {
size = uint64(r.ContentLength)
}
return size
return uint64(decodedSize)
}
func parseRange(s string) (*layer.RangeParams, error) {