Repository navigation
http: compute body chunk length from decoded bytes - #67615
Open
ShogunPanda wants to merge 1 commit into
Open
ShogunPanda wants to merge 1 commit into
ShogunPanda wants to merge 1 commit into
Conversation
Convert base64, base64url and hex strings to a Buffer before computing the chunk length, so the announced length matches the bytes written even when the input contains characters skipped while decoding. Assisted-By: OpenAI GPT-5.6 Sol <openai/gpt-5.6-sol> Signed-off-by: Paolo Insogna <paolo@cowtech.it>
Collaborator
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #67615 +/- ##
==========================================
- Coverage 90.72% 90.71% -0.02%
==========================================
Files 801 801
Lines 280809 280831 +22
Branches 54212 54217 +5
==========================================
- Hits 254776 254753 -23
- Misses 16209 16244 +35
- Partials 9824 9834 +10
🚀 New features to boost your workflow:
|
jazelly
reviewed
Nov 20, 2026
| // invalid pair). | ||
| function decodeLossyEncodedChunk(chunk, encoding) { | ||
| if (typeof chunk === 'string' && typeof encoding === 'string') { | ||
| switch (encoding.toLowerCase()) { |
Member
There was a problem hiding this comment.
We have a normalizeEncoding method in internal/util. Would that be better?
This comment was marked as off-topic.
This comment was marked as off-topic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OutgoingMessagecomputed the chunk length withBuffer.byteLength(string, encoding), which is only an upper bound for base64, base64url and hex input: whitespace and invalid characters are skipped while decoding. The announced chunk (or Content-Length) could therefore be larger than the bytes actually written.This decodes such strings to a Buffer first, in
write()andend(), so all length computations use the real byte count, and adds a test.AI-assisted work. All changes reviewed by a human.