Refactor conditions on body producer

This commit is contained in:
Paul Tremberth 2017-04-24 22:08:39 +02:00
parent 99e3c0d653
commit 97fc68fa16
1 changed files with 3 additions and 1 deletions

View File

@ -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)