Skip to content

Add support for streaming identity-encoded or unknown length response bodies#2000

Merged
erikdubbelboer merged 1 commit intovalyala:masterfrom
osxtest:streaming
May 3, 2025
Merged

Add support for streaming identity-encoded or unknown length response bodies#2000
erikdubbelboer merged 1 commit intovalyala:masterfrom
osxtest:streaming

Conversation

@osxtest
Copy link
Copy Markdown
Contributor

@osxtest osxtest commented Apr 28, 2025

This change adds support for streaming response bodies when the Transfer-Encoding is identity (or when Content-Length is not provided).

}
left := rs.header.ContentLength() - rs.totalBytesRead
if len(p) > left {
if left > 0 && len(p) > left {
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.

Update the read size of p only when left is greater than zero.

  • left cannot be zero here, as the previous check if rs.totalBytesRead == rs.header.ContentLength() { ... } already handles that case.
  • left may be negative if rs.header.ContentLength() returns -2, which can occur when Transfer-Encoding: identity is used or when Content-Length is not provided.

@erikdubbelboer erikdubbelboer merged commit 1345f42 into valyala:master May 3, 2025
10 of 11 checks passed
@erikdubbelboer
Copy link
Copy Markdown
Collaborator

Thanks!

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