mirror of
https://github.com/scrapy/scrapy.git
synced 2025-02-26 17:04:07 +00:00
added Content-Length header population to Common downloader middleware
--HG-- extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40754
This commit is contained in:
parent
1e002a0c98
commit
12d0bd4dbb
@ -34,6 +34,9 @@ thus it's recommended to leave it always enabled. Those tasks are:
|
||||
* If the request method is ``POST`` and the ``Content-Type`` header is not
|
||||
set, then set it to ``'application/x-www-form-urlencoded'``, the `default
|
||||
Form content type`_.
|
||||
|
||||
* If the request contains a body and the ``Content-Length`` headers it not
|
||||
set, then set it to the ``len(body)``.
|
||||
|
||||
.. _default Form content type: http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1
|
||||
|
||||
|
@ -17,4 +17,6 @@ class CommonMiddleware(object):
|
||||
request.headers.setdefault('Accept-Language', self.header_accept_language)
|
||||
if request.method == 'POST':
|
||||
request.headers.setdefault('Content-Type', 'application/x-www-form-urlencoded')
|
||||
if request.body:
|
||||
request.headers.setdefault('Content-Length', '%d' % len(request.body))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user