Is there a reason why CONTENT-LENGTH is always blank in the environ
dictionary that gets passed to WSGIRequest ?
(django/core/handlers/wsgi.py)
Why isn't it just automatically computed based on the length of the
request's content?
The reason I ask is because I'm getting an exception raised on line 119
in wsgi.py when the WSGI object tries to return its raw post data:
self._raw_post_data =
self.environ['wsgi.input'].read(int(self.environ["CONTENT_LENGTH"]))
ValueError: invalid literal for int():
, which fails because of the empty string value.
Thanks,
Martin
What web server front-end are you using to handle the request?
Development server? Twisted? Other?
>
> Why isn't it just automatically computed based on the length of the
> request's content?
I'm not sure in this specific case, but in general this is not going to
always be possible. For example, if the incoming content is passed to
the handler before it is fully received (streaming input). Django does
not have good streaming input handling at the moment, so that will not
be the case here, but I just want to point out that the solution is not
necessarily as simple as this.
>
> The reason I ask is because I'm getting an exception raised on line 119
> in wsgi.py when the WSGI object tries to return its raw post data:
>
> self._raw_post_data =
> self.environ['wsgi.input'].read(int(self.environ["CONTENT_LENGTH"]))
> ValueError: invalid literal for int():
>
> , which fails because of the empty string value.
On all requests, or only on a particular type of request?
Regards,
Malcolm
If you want to set the "content-length" header, use the
ConditionalGetMiddleware middleware component.
Django doesn't do this by default for performance.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com