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: automatically add content-length for small responses #3989

Merged
merged 9 commits into from Aug 21, 2023

Conversation

WeidiDeng
Copy link
Contributor

…all enough and doesn't call Flush

Another iteration of 3954.

@codecov
Copy link

codecov bot commented Jul 22, 2023

Codecov Report

Merging #3989 (50a6ed0) into master (3822dae) will increase coverage by 0.01%.
The diff coverage is 82.61%.

@@            Coverage Diff             @@
##           master    #3989      +/-   ##
==========================================
+ Coverage   82.94%   82.95%   +0.01%     
==========================================
  Files         147      147              
  Lines       14781    14801      +20     
==========================================
+ Hits        12260    12278      +18     
- Misses       2022     2025       +3     
+ Partials      499      498       -1     
Files Changed Coverage Δ
http3/response_writer.go 84.00% <80.49%> (+0.67%) ⬆️
http3/server.go 77.73% <100.00%> (+0.81%) ⬆️

... and 1 file with indirect coverage changes

@WeidiDeng
Copy link
Contributor Author

@marten-seemann Do you have time to take a look at this pr?

@marten-seemann marten-seemann changed the title response writer: add content-length automatically when response is sm… http3: automatically add content-length for small responses Aug 5, 2023
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 for this PR!

Can you add an integration test (in http_test.go) that tests end-to-end that this actually works?

I'm also wondering if we should have any logic to send out large (> 1 MTU?) headers without waiting for the write call. What do you think?

http3/response_writer.go Outdated Show resolved Hide resolved
http3/response_writer.go Outdated Show resolved Hide resolved
http3/response_writer.go Outdated Show resolved Hide resolved
http3/response_writer.go Outdated Show resolved Hide resolved
@WeidiDeng
Copy link
Contributor Author

I don't known if we should flush headers immediately for large headers 😅 , as far as I know, I use this branch and previous one without encountering any problems at all.

@WeidiDeng
Copy link
Contributor Author

I don't know why these connection tests failed 🤷 .

@@ -15,7 +15,12 @@ import (
"github.com/quic-go/qpack"
)

// headerWriter wrap the stream, so first Write will flush header to the stream
// The maximum length of an encoded quic frame header is 10.
// 1 (header type) + variable (frame length, the length of the largest encoded quic varint is 9).
Copy link
Member

Choose a reason for hiding this comment

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

It's 8.

Copy link
Member

Choose a reason for hiding this comment

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

The type is not guaranteed to be 1 byte though, is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

16 comes from the original code for encoding frame header. The type is 1 byte for header and data frame according to the code.

It's 8 byte. My mistake.

http3/response_writer.go Outdated Show resolved Hide resolved
@marten-seemann marten-seemann merged commit 824fd8a into quic-go:master Aug 21, 2023
18 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.

None yet

2 participants