[HTTP/1.1] Skip Content-Length header if its value is UNKNOWN_LENGTH (#5062)

This commit is contained in:
Eugenio Lacuesta 2021-03-25 11:58:39 -03:00 committed by GitHub
parent f0e1a33225
commit 9c9e1a318d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

View File

@ -361,10 +361,9 @@ class ScrapyAgent:
@staticmethod
def _headers_from_twisted_response(response):
headers = Headers()
if response.length is not None:
if response.length != UNKNOWN_LENGTH:
headers[b'Content-Length'] = str(response.length).encode()
for key, value in response.headers.getAllRawHeaders():
headers[key] = value
headers.update(response.headers.getAllRawHeaders())
return headers
def _cb_bodyready(self, txresponse, request):