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-Type and Content-Length are set to empty string in test environment #1159

Closed
f11r opened this issue Aug 3, 2017 · 1 comment
Closed

Comments

@f11r
Copy link

f11r commented Aug 3, 2017

At the moment in the test environment the Content-Type and Content-Length headers are always set (see

'CONTENT_LENGTH': str(content_length or '0'),
), even if not provided by the user. This makes the following calls identical and stops anyone from testing a call without one of these headers:

resp = app_client.post('/v1.0/post_wrong_content_type', data=json.dumps({'some': 'data'}))
resp = app_client.post('/v1.0/post_wrong_content_type', data=json.dumps({'some': 'data'}), 
                       content_type='')

This seems very similar to #1049.

@mitsuhiko
Copy link
Contributor

This is permitted by the WSGI spec:

The following variables must be present, unless their value would be an empty string, in which case they may be omitted, except as otherwise noted below

The contents of any Content-Type fields in the HTTP request. May be empty or absent.

We generally treat missing and set empty the same.

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

No branches or pull requests

2 participants