Scrapy, a fast high-level web crawling & scraping framework for Python.
Fixed bug with no specified Content-Length header by ScrapyHTTPClientFactory for POST request with no given body
drack3800549882590bfd
diff --git a/scrapy/core/downloader/webclient.py b/scrapy/core/downloader/webclient.pyindex 2c6a61b8a..22c461b15 100644--- a/scrapy/core/downloader/webclient.py+++ b/scrapy/core/downloader/webclient.py@@ -112,12 +112,15 @@ class ScrapyHTTPClientFactory(HTTPClientFactory):# set Host header based on urlself.headers.setdefault('Host', self.netloc)-+# set Content-Length based len of bodyif self.body is not None:self.headers['Content-Length'] = len(self.body)# just in case a broken http/1.1 decides to keep connection aliveself.headers.setdefault("Connection", "close")+ # Content-Length must be specified in POST method even with no body+ elif self.method == 'POST':+ self.headers['Content-Length'] = 0def _build_response(self, body, request):request.meta['download_latency'] = self.headers_time-self.start_time