From 862f0301e2cb166ca87ce985d51683b46dcf56ad Mon Sep 17 00:00:00 2001 From: Eugenio Lacuesta Date: Sun, 5 Apr 2020 00:53:10 -0300 Subject: [PATCH] Remove empty _RequestBodyProducer for POST requests --- scrapy/core/downloader/handlers/http11.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/scrapy/core/downloader/handlers/http11.py b/scrapy/core/downloader/handlers/http11.py index c970909d7..09f828419 100644 --- a/scrapy/core/downloader/handlers/http11.py +++ b/scrapy/core/downloader/handlers/http11.py @@ -341,20 +341,6 @@ class ScrapyAgent: headers.removeHeader(b'Proxy-Authorization') if request.body: bodyproducer = _RequestBodyProducer(request.body) - elif method == b'POST': - # Setting Content-Length: 0 even for POST requests is not a - # MUST per HTTP RFCs, but it's common behavior, and some - # servers require this, otherwise returning HTTP 411 Length required - # - # RFC 7230#section-3.3.2: - # "a Content-Length header field is normally sent in a POST - # request even when the value is 0 (indicating an empty payload body)." - # - # Twisted < 17 will not add "Content-Length: 0" by itself; - # Twisted >= 17 fixes this; - # Using a producer with an empty-string sends `0` as Content-Length - # for all versions of Twisted. - bodyproducer = _RequestBodyProducer(b'') else: bodyproducer = None start_time = time()