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

http3: sniff Content-Type when flushing the ResponseWriter #4412

Merged
merged 11 commits into from
Apr 27, 2024

Conversation

WeidiDeng
Copy link
Contributor

When caddy log is enabled, it can be observed Content-Type sniffing no longer works for http3, but works for h1/2. This is caused because when logging is enabled, caddy wraps all response writers with responseRecorder which will call WriteHeader first.

Stdlib will try set Content-Type header in the same logic, for http1, *chunkWriter is wrapped by *response to write the actual data. http2 will set this header in the same way.

Because this header is set once, it won't be overwritten automatically

Copy link

codecov bot commented Apr 5, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 84.78%. Comparing base (083ceb4) to head (0ff1f51).
Report is 1 commits behind head on master.

Files Patch % Lines
http3/response_writer.go 50.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4412      +/-   ##
==========================================
- Coverage   84.79%   84.78%   -0.01%     
==========================================
  Files         154      154              
  Lines       14645    14647       +2     
==========================================
  Hits        12418    12418              
- Misses       1715     1716       +1     
- Partials      512      513       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@marten-seemann
Copy link
Member

@WeidiDeng The large refactor for HTTP Datagram support (#4452) was merged. Do you want to update this PR?

@marten-seemann marten-seemann self-requested a review April 27, 2024 10:07
Copy link
Member

@marten-seemann marten-seemann left a comment

Choose a reason for hiding this comment

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

This looks a lot cleaner now.

Do I understand correctly that the only thing that this PR changes is that the sniffing algorithm is now also run when flushing, whereas before it was only run on Write?

http3/response_writer.go Outdated Show resolved Hide resolved
@marten-seemann marten-seemann added this to the v0.43 milestone Apr 27, 2024
@marten-seemann
Copy link
Member

This PR is the only thing left for the v0.43 release.

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
@marten-seemann
Copy link
Member

Do I understand correctly that the only thing that this PR changes is that the sniffing algorithm is now also run when flushing, whereas before it was only run on Write?

@WeidiDeng Can you confirm this?

@marten-seemann marten-seemann changed the title try to sniff content-type as long as the data is not flushed http3: sniff Content-Type when flushing the ResponseWriter Apr 27, 2024
@WeidiDeng
Copy link
Contributor Author

@marten-seemann Yes, I confirm that's the change.

Copy link
Member

@marten-seemann marten-seemann left a comment

Choose a reason for hiding this comment

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

Thank you @WeidiDeng!

@marten-seemann marten-seemann merged commit 93c4785 into quic-go:master Apr 27, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants