Skip to content

fix: preserve Content-Length header in MITM responses#102

Merged
guyb1 merged 1 commit intomainfrom
fix/preserve-content-length-in-responses
Mar 25, 2026
Merged

fix: preserve Content-Length header in MITM responses#102
guyb1 merged 1 commit intomainfrom
fix/preserve-content-length-in-responses

Conversation

@guyb1
Copy link
Copy Markdown
Contributor

@guyb1 guyb1 commented Mar 25, 2026

I have read the CONTRIBUTING.md file.

YES

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

The gateway's hop-by-hop header filter strips Content-Length from both request and response headers. This breaks HEAD responses — clients like huggingface_hub that rely on Content-Length in HEAD responses to resolve model file sizes get empty values.

Closes #101

What is the new behavior?

Split is_forwarded_header into two focused functions:

  • is_forwarded_request_header — strips Content-Length (reqwest recalculates it from the body)
  • is_forwarded_response_header — preserves Content-Length (required for HEAD responses and correct HTTP/1.1 framing)

Shared HOP_BY_HOP_HEADERS constant eliminates duplication between the two functions.

Additional context

  • Extracted hop-by-hop header list into a constant for single source of truth
  • Added 6 focused tests covering both request and response header filtering
  • All 103 unit tests + 5 integration tests pass, clippy clean

@guyb1 guyb1 force-pushed the fix/preserve-content-length-in-responses branch from 723f061 to 6533176 Compare March 25, 2026 09:21
@guyb1 guyb1 merged commit 21ee091 into main Mar 25, 2026
1 check passed
@guyb1 guyb1 deleted the fix/preserve-content-length-in-responses branch March 25, 2026 09:29
@guyb1 guyb1 mentioned this pull request Mar 25, 2026
hisgarden pushed a commit to hisgarden/onecli that referenced this pull request Mar 27, 2026
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.

Content length is stripped in response headers.

1 participant