decode body from utf-8, as scrapy stores body as bytes, and twisted has already converted to unicode

This commit is contained in:
Konstantin Lopuhin 2016-01-14 12:03:08 +03:00
parent 9f2be23a39
commit 73ff87c1dc
1 changed files with 3 additions and 0 deletions

View File

@ -132,6 +132,9 @@ class ScrapyHTTPClientFactory(HTTPClientFactory):
status = int(self.status)
headers = Headers(self.response_headers)
respcls = responsetypes.from_args(headers=headers, url=self.url)
# XXX - scrapy response stores body as bytes,
# but maybe it makes sense to be able to store unicode?
body = to_bytes(body)
return respcls(url=self.url, status=status, headers=headers, body=body)
def _set_connection_attributes(self, request):