Scrapy, a fast high-level web crawling & scraping framework for Python.
Avoid sending Content-Length header when body is an empty string.
Daniel Grana8fdf06ed08c5
diff --git a/scrapy/trunk/docs/ref/request-response.rst b/scrapy/trunk/docs/ref/request-response.rstindex 5cf7fabbb..000dc0e72 100644--- a/scrapy/trunk/docs/ref/request-response.rst+++ b/scrapy/trunk/docs/ref/request-response.rst@@ -41,8 +41,10 @@ Request objects``meta`` is a dict containing the initial values for the:attr:`Request.meta` attribute. If passed, the dict will be shallow copied.- ``body`` is a str or unicode containing the request body. If ``body`` is- a `unicode` it's encoded to str using the `encoding` passed.+ ``body`` is a str or unicode containing the request body.+ If ``body`` is a `unicode` it's encoded to str using the `encoding` passed.+ If ``body`` is None, an empty string is stored.+ In any case, the final stored value will be a string (never unicode, never None).``headers`` is a multi-valued dict containing the headers of this requestdiff --git a/scrapy/trunk/scrapy/core/downloader/handlers.py b/scrapy/trunk/scrapy/core/downloader/handlers.pyindex ae74e1710..23f7a5af3 100644--- a/scrapy/trunk/scrapy/core/downloader/handlers.py+++ b/scrapy/trunk/scrapy/core/downloader/handlers.py@@ -53,7 +53,7 @@ def create_factory(request, spider):agent = request.headers.pop('user-agent', default_agent)factory = HTTPClientFactory(url=url, # never pass unicode urls to twistedmethod=request.method,- postdata=request.body,+ postdata=request.body or None,headers=request.headers,agent=agent,cookies=request.cookies,