Skip to content

Fix unkown length response#550

Open
TingDaoK wants to merge 12 commits intomainfrom
fix-unkown-length-response
Open

Fix unkown length response#550
TingDaoK wants to merge 12 commits intomainfrom
fix-unkown-length-response

Conversation

@TingDaoK
Copy link
Copy Markdown
Contributor

Issue #, if available:

Description of changes:

  • The HTTP client currently treat the response completes after the headers if no transfer encoding nor content-length received.
  • But, the SPEC clearly mentioned that is a valid case for the response to provide indeterminate length response. (But request is not allowed to do so.)
  • Add support to handle the case by leave the decoder

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@TingDaoK TingDaoK marked this pull request as ready for review February 21, 2026 00:28
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 92.85714% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.71%. Comparing base (da535b1) to head (fb35f9e).

Files with missing lines Patch % Lines
source/h1_connection.c 75.00% 1 Missing ⚠️
source/h1_decoder.c 95.83% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #550      +/-   ##
==========================================
- Coverage   79.78%   79.71%   -0.08%     
==========================================
  Files          28       28              
  Lines       12082    12110      +28     
==========================================
+ Hits         9640     9653      +13     
- Misses       2442     2457      +15     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread source/h1_decoder.c Outdated
/* RFC-7230 section 3.3 Message Body */
decoder->body_headers_ignored |= code_val == AWS_HTTP_STATUS_CODE_304_NOT_MODIFIED;
if (decoder->body_headers_ignored_on_2xx) {
decoder->body_headers_ignored |= code_val / 200 == 1;
Copy link
Copy Markdown
Contributor

@azkrishpy azkrishpy Mar 4, 2026

Choose a reason for hiding this comment

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

2xx (Successful) responses to a CONNECT request method (Section 4.3.6 of[RFC7231]) 
switch to tunnel mode instead of having a message body. All 1xx (Informational), 
204 (No Content), and 304 (Not Modified) responses do not include a message body.  
All other responses do include a message body, although the body might be of zero length.

we seem to ignore body for any value between 200 and 400? Is that correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah, I was wrong about the math, this is supposed to be status code from 200-299.
Good catch!

…nups

- Fix code_val/200==1 to code_val/100==2 (matched 200-399 instead of 200-299)
- Add unit tests for indeterminate-length response body:
  - h1_client_response_indeterminate_length_body (multi-chunk body)
  - h1_client_response_indeterminate_length_empty_body (empty body edge case)
  - h1_client_response_204_no_indeterminate_length (negative case)
- Fix typo: 'response lien' -> 'response line'
- Reset body_headers_ignored_on_2xx in s_reset_state() for consistency
- Fix inconsistent Server header in mock server ('echo-server' -> 'crt-local-server')
# Conflicts:
#	tests/CMakeLists.txt
#	tests/test_h1_client.c
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.

3 participants