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

Fix request body handling in gthread worker #3303

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

oallenj
Copy link

@oallenj oallenj commented Sep 30, 2024

Fixes #3301.

The problem is that if the request body is not read and the gthread worker finishes handling a request with a large request body, it will see that the socket is still readable and call on_client_socket_readable. However, the readable bytes are just the rest of the request body. The part of the code annotated "Discard any unread body of the previous message" will discard that request body, but gthread will then proceed to subsequently try and read a full HTTP request, which may have not been sent. This change will discard the request body after handling a request, and before on_client_socket_readable can be called so this doesn't happen.

I'm not sure how to make a test for this because it requires multiple connections and doesn't seem to fit in with the rest of gunicorn's test suite.

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.

gthread worker will block
1 participant