use byte constants for prefix instead of encoding it

This commit is contained in:
Konstantin Lopuhin 2016-01-20 23:30:58 +03:00
parent a5da7531c4
commit fd24e22442
1 changed files with 2 additions and 3 deletions

View File

@ -29,16 +29,15 @@ class Command(ScrapyCommand):
help="print response HTTP headers instead of body")
def _print_headers(self, headers, prefix):
prefix = prefix.encode()
for key, values in headers.items():
for value in values:
self._print_bytes(prefix + b' ' + key + b': ' + value)
def _print_response(self, response, opts):
if opts.headers:
self._print_headers(response.request.headers, '>')
self._print_headers(response.request.headers, b'>')
print('>')
self._print_headers(response.headers, '<')
self._print_headers(response.headers, b'<')
else:
self._print_bytes(response.body)