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

Content-Length Handling #32

Open
cirospaciari opened this issue Mar 13, 2023 · 0 comments
Open

Content-Length Handling #32

cirospaciari opened this issue Mar 13, 2023 · 0 comments

Comments

@cirospaciari
Copy link

cirospaciari commented Mar 13, 2023

When Content-Length mismatch happens with the provided value being bigger than the real value the connection is not closed.
The response is still correct with Content-Length: 26.

In this case meinheld, gunicorn and socketify would close the connection.

def app_hello(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain'), ('Content-Length', '30')])
    
    return [b'Hello, World!', b'Hello, World!']

If the real response is bigger than the Content-Length provided, meinheld and gunicorn will just end the response when reaches the length provided.
image

def app_hello(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain'), ('Content-Length', '24')])
    
    return [b'Hello, World!', b'Hello, World!']

fastWSGI close the connection in this case, socketify also does this, and I think is better to close and emit a warning when Content-Length mismatch happens.

But in case the Content-Length is bigger than the real response, I think that should be better to also close the connection to keep the same behavior and to warn that something that the user/framework wants to send will not be sent.

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

No branches or pull requests

1 participant