]> source.dussan.org Git - gitea.git/commit
Add Content-Length header to HEAD requests (#14542)
authorFarid AYOUJIL <faridtsl@users.noreply.github.com>
Fri, 5 Feb 2021 20:10:40 +0000 (21:10 +0100)
committerGitHub <noreply@github.com>
Fri, 5 Feb 2021 20:10:40 +0000 (21:10 +0100)
commitf72ce26326ea31d4bea8116e11c4c4f96b68639d
treea5bc937906107d6807e4f25fe1d5d1ff5f3df124
parent4457d0e8d9b09e7577242a8bc005ef9d43be4e8c
Add Content-Length header to HEAD requests (#14542)

* Add Content-Length header to HEAD requests

This change adds the header Content-Length to HEAD HTTP requests.

The previous behaviour was blocking some Windows executables (i.e
bitsadmin.exe) from downloading files hosted in Gitea.

This along with PR #14541, makes the web server compliant with HTTP RFC 2616 which states
"The methods GET and HEAD MUST be supported by all general-purpose servers"
and
"The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response."

This should also respond to issues #8030 and #14532.

* This change adds the header Content-Length to HEAD HTTP requests

Pass the Size of the content as a parameter to ServeData() instead of
calculating it using ioutil.ReadAll(reader) --> this call is dangerous
and can result in a denial of service.

* Add Content-Length header to HEAD requests

Quick fix for imported dependency not used.

* Check if size is positiv int ...

Co-authored-by: zeripath <art27@cantab.net>
routers/repo/attachment.go
routers/repo/download.go