Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Refactor conditions on body producer

Paul Tremberth97fc68fa1699
diff --git a/scrapy/core/downloader/handlers/http11.py b/scrapy/core/downloader/handlers/http11.py
index bff4a30c9..46493f87f 100644
--- a/scrapy/core/downloader/handlers/http11.py
+++ b/scrapy/core/downloader/handlers/http11.py
@@ -279,8 +279,10 @@ class ScrapyAgent(object):
headers.removeHeader(b'Proxy-Authorization')
if request.body:
bodyproducer = _RequestBodyProducer(request.body)
+ elif method == b'POST':
+ bodyproducer = _RequestBodyProducer(b'')
else:
- bodyproducer = _RequestBodyProducer(b'') if method == b'POST' else None
+ bodyproducer = None
start_time = time()
d = agent.request(
method, to_bytes(url, encoding='ascii'), headers, bodyproducer)