Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Ensure empty body responses never generate an invalid chunked response #4710

Merged
merged 5 commits into from
Nov 15, 2023

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Nov 14, 2023

Proposed change

aiohttp < 3.9.0 (fixed in aio-libs/aiohttp#7756) will generate an invalid chunked response aka "0\r\n\r\n" instead of an actual empty body if we reached the streaming handler for 204, 304, and a few other cases. Additionally its inefficient to send a StreamResponse when a normal Response will do in these cases.

I tested this changed with core running aiohttp 3.9.0rc0 and 3.8.5, and supervisor running aiohttp 3.8.6 and 3.9.0rc0

When we upgrade to 3.9.0 we should replace this check with the aiohttp must_be_empty_body helper:
https://github.com/aio-libs/aiohttp/blob/8ae650bee4add9f131d49b96a0a150311ea58cd1/aiohttp/helpers.py#L1061

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionality to the supervisor)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to cli pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast supervisor tests)
  • Tests have been added to verify that the new code works.

If API endpoints of add-on configuration are added/changed:

aiohttp < 3.9.0 will generate an invalid chunked response
if we reached the streaming handler for 204, 304, and a few
other cases. Additionally its inefficient to send a StreamResponse
when a normal Response will do.

When we upgrade to 3.9.0 we should replace this check with the aiohttp
must_be_empty_body helper:
https://github.com/aio-libs/aiohttp/blob/8ae650bee4add9f131d49b96a0a150311ea58cd1/aiohttp/helpers.py#L1061
aiohttp < 3.9.0 will generate an invalid chunked response
if we reached the streaming handler for 204, 304, and a few
other cases. Additionally its inefficient to send a StreamResponse
when a normal Response will do.

When we upgrade to 3.9.0 we should replace this check with the aiohttp
must_be_empty_body helper:
https://github.com/aio-libs/aiohttp/blob/8ae650bee4add9f131d49b96a0a150311ea58cd1/aiohttp/helpers.py#L1061
aiohttp < 3.9.0 will generate an invalid chunked response
if we reached the streaming handler for 204, 304, and a few
other cases. Additionally its inefficient to send a StreamResponse
when a normal Response will do.

When we upgrade to 3.9.0 we should replace this check with the aiohttp
must_be_empty_body helper:
https://github.com/aio-libs/aiohttp/blob/8ae650bee4add9f131d49b96a0a150311ea58cd1/aiohttp/helpers.py#L1061
aiohttp < 3.9.0 will generate an invalid chunked response
if we reached the streaming handler for 204, 304, and a few
other cases. Additionally its inefficient to send a StreamResponse
when a normal Response will do.

When we upgrade to 3.9.0 we should replace this check with the aiohttp
must_be_empty_body helper:
https://github.com/aio-libs/aiohttp/blob/8ae650bee4add9f131d49b96a0a150311ea58cd1/aiohttp/helpers.py#L1061
aiohttp < 3.9.0 will generate an invalid chunked response
if we reached the streaming handler for 204, 304, and a few
other cases. Additionally its inefficient to send a StreamResponse
when a normal Response will do.

When we upgrade to 3.9.0 we should replace this check with the aiohttp
must_be_empty_body helper:
https://github.com/aio-libs/aiohttp/blob/8ae650bee4add9f131d49b96a0a150311ea58cd1/aiohttp/helpers.py#L1061
@bdraco bdraco marked this pull request as ready for review November 14, 2023 22:30
Copy link
Member

@agners agners left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

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

Thanks, @bdraco 👍

../Frenck

@frenck frenck merged commit cca74da into main Nov 15, 2023
22 of 23 checks passed
@frenck frenck deleted the 204_304 branch November 15, 2023 10:44
@bdraco
Copy link
Member Author

bdraco commented Nov 15, 2023

Thanks

@github-actions github-actions bot locked and limited conversation to collaborators Nov 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants