Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Attempt to prevent responses with Transfer-Encoding: chunked #288

Merged
merged 2 commits into from
May 2, 2022

Conversation

jeremyevans
Copy link
Contributor

It's probably a bad idea to implement Transfer-Encoding
chunked inside an application, since only HTTP/1.1 supports
it. However, some applications and frameworks still do so.
However, they should only do so if they receive an HTTP/1.1
request, it's certainly a bug in the application to use
Transfer-Encoding: chunked for HTTP/1.0 requests.

Set SERVER_PROTOCOL and HTTP_VERSION to HTTP/1.0 in requests
to try to avoid responses with Transfer-Encoding: chunked.

While here, avoid 4 unnecessary hash allocations by using
either Hash#merge! instead of #merge, or using Hash#[]=
instead of allocating a hash to pass to Hash#update.

It's probably a bad idea to implement Transfer-Encoding
chunked inside an application, since only HTTP/1.1 supports
it.  However, some applications and frameworks still do so.
However, they should only do so if they receive an HTTP/1.1
request, it's certainly a bug in the application to use
Transfer-Encoding: chunked for HTTP/1.0 requests.

Set SERVER_PROTOCOL and HTTP_VERSION to HTTP/1.0 in requests
to try to avoid responses with Transfer-Encoding: chunked.

While here, avoid 4 unnecessary hash allocations by using
either Hash#merge! instead of #merge, or using Hash#[]=
instead of allocating a hash to pass to Hash#update.
This currently still runs rubocop, but rubocop failure does not
cause workflow failure and won't block merging.
Copy link
Member

@ioquatix ioquatix left a comment

Choose a reason for hiding this comment

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

I'm fine with this.

However I feel that the testing layer should be capable of dealing with different body formats. There are some semantic differences between chunked encoding and content length encoding and in theory we should support testing them.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants