gitea/routers/repo
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
..
activity.go
attachment.go
blame.go
branch.go
commit.go
compare.go
download.go
editor_test.go
editor.go
http.go
issue_dependency.go
issue_label_test.go
issue_label.go
issue_lock.go
issue_stopwatch.go
issue_test.go
issue_timetrack.go
issue_watch.go
issue.go
lfs.go
main_test.go
middlewares.go
migrate.go
milestone.go
projects_test.go
projects.go
pull_review.go
pull.go
release_test.go
release.go
repo.go
search.go
setting_protected_branch.go
setting.go
settings_test.go
topic.go
view.go
webhook.go
wiki_test.go
wiki.go