0
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-11-28 14:23:11 +01:00
gitea/routers
Farid AYOUJIL f72ce26326
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>
2021-02-05 21:10:40 +01:00
..
admin Update docs and comments to remove macaron (#14491) 2021-01-29 16:35:30 +01:00
api/v1 [API] GetRelease by tag only return release (#14397) 2021-02-04 04:12:25 +01:00
dev
events
org
private
repo Add Content-Length header to HEAD requests (#14542) 2021-02-05 21:10:40 +01:00
routes Adding Chi's GetHead middleware (#14541) 2021-02-02 10:53:42 +02:00
user Honor REGISTER_MANUAL_CONFIRM when doing openid registration (#14548) 2021-02-05 04:03:20 +01:00
utils
home.go
init.go
install.go Move middlewares to web/middleware (#14480) 2021-01-30 10:55:53 +02:00
metrics.go
swagger_json.go