-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Conversation
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 <[email protected]>
hmm... this is wrong and breaks tests... |
implementations will always do it for us Signed-off-by: Andrew Thornton <[email protected]>
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
@@ -49,7 +49,7 @@ func (r *Response) Write(bs []byte) (int, error) { | |||
return size, err | |||
} | |||
if r.status == 0 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
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 <[email protected]> Co-authored-by: Lauris BH <[email protected]>
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 <[email protected]>
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 <[email protected]> Co-authored-by: Lauris BH <[email protected]>
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 [email protected]