Working on PR for "Missing HEAD method when the code moved to chi" #14532
Labels
issue/needs-feedback
For bugs, we need more details. For features, the feature must be described in more detail
Description
When I was trying to fix issue #8030 I had a look at the code base. Then two days later it moved from Macaron to Chi, the HEAD HTTP method no longer works automatically when GET is defined.
I already added and tested the code locally. Adding this line to WebRoutes function in 'routers/routes/web.go' fixes the issue.
As for fixing issue #8030 :
This is a problem when trying to make a program download from Gitea. For example, Windows executables break when trying to download from Gitea /raw route as it does not give "Content-Length" in HEAD response.
The only function that needed to change is ServeData in 'routers/repo/download.go'. By changing the call to io.Copy to ioutil.ReadAll() + ctx.Resp.Write() . Then Writing the Content-Length explicitly by taking the length of the ioutil.ReadAll() byte array.
Questions :
1- Are the design decisions good ? should I make a PR ?
2- Should I make one or two PRs ?
3- I have no idea how to write tests these two functionalities ?
Related issues
#8030
The text was updated successfully, but these errors were encountered: