Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop calling WriteHeader in Write #15862

Merged
merged 4 commits into from
May 14, 2021

Conversation

zeripath
Copy link
Contributor

@zeripath zeripath commented May 13, 2021

Go's write function will do it for us anyway

Fixes http: superfluous response.WriteHeader call from code.gitea.io/gitea/modules/context.(*Response).WriteHeader (response.go:67)

Signed-off-by: Andrew Thornton art27@cantab.net

The header should be written before the first write.

Fixes http: superfluous response.WriteHeader call from code.gitea.io/gitea/modules/context.(*Response).WriteHeader (response.go:67)

Signed-off-by: Andrew Thornton <art27@cantab.net>
routers/repo/attachment.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 13, 2021
routers/repo/attachment.go Outdated Show resolved Hide resolved
routers/repo/attachment.go Outdated Show resolved Hide resolved
routers/repo/download.go Outdated Show resolved Hide resolved
routers/repo/download.go Outdated Show resolved Hide resolved
routers/repo/download.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 13, 2021
@zeripath
Copy link
Contributor Author

hmm... this is wrong and breaks tests...

implementations will always do it for us

Signed-off-by: Andrew Thornton <art27@cantab.net>
@codecov-commenter
Copy link

codecov-commenter commented May 13, 2021

Codecov Report

Merging #15862 (6fbc2c7) into main (05fb1f6) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15862      +/-   ##
==========================================
- Coverage   44.00%   44.00%   -0.01%     
==========================================
  Files         681      681              
  Lines       82253    82253              
==========================================
- Hits        36198    36193       -5     
- Misses      40147    40153       +6     
+ Partials     5908     5907       -1     
Impacted Files Coverage Δ
modules/context/response.go 80.55% <100.00%> (ø)
modules/log/log.go 58.08% <0.00%> (-2.95%) ⬇️
models/repo_list.go 77.04% <0.00%> (-0.78%) ⬇️
models/gpg_key.go 53.51% <0.00%> (-0.57%) ⬇️
services/pull/pull.go 43.83% <0.00%> (+0.45%) ⬆️
modules/queue/unique_queue_disk_channel.go 55.22% <0.00%> (+1.49%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 05fb1f6...6fbc2c7. Read the comment docs.

@@ -49,7 +49,7 @@ func (r *Response) Write(bs []byte) (int, error) {
return size, err
}
if r.status == 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or move this to line 45

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that breaks tests somehow as it results in breaking the contenttype detection.

Go will now always ensure that the header is written before it writes so I don't think we need the writeheader anymore

@zeripath zeripath changed the title WriteHeader should be called before Write not after. Stop calling WriteHeader in Write May 14, 2021
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 14, 2021
@lafriks lafriks merged commit 2d87a84 into go-gitea:main May 14, 2021
@zeripath zeripath deleted the fix-superfluous-writeHeader branch May 14, 2021 08:12
zeripath added a commit to zeripath/gitea that referenced this pull request May 14, 2021
Backport go-gitea#15862

Fixes http: superfluous response.WriteHeader call from code.gitea.io/gitea/modules/context.(*Response).WriteHeader (response.go:67)

* Looking again we don't need this writeHeader as all of our downstream
implementations will always do it for us

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
@zeripath zeripath added the backport/done All backports for this PR have been created label May 14, 2021
zeripath added a commit that referenced this pull request May 14, 2021
Backport #15862

Fixes http: superfluous response.WriteHeader call from code.gitea.io/gitea/modules/context.(*Response).WriteHeader (response.go:67)

* Looking again we don't need this writeHeader as all of our downstream
implementations will always do it for us

Signed-off-by: Andrew Thornton <art27@cantab.net>
AbdulrhmnGhanem pushed a commit to kitspace/gitea that referenced this pull request Aug 10, 2021
Fixes http: superfluous response.WriteHeader call from code.gitea.io/gitea/modules/context.(*Response).WriteHeader (response.go:67)

* Looking again we don't need this writeHeader as all of our downstream
implementations will always do it for us

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
@go-gitea go-gitea locked and limited conversation to collaborators Oct 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants