From 0293ba179916b784b86c05bbb41ba24487058091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Roztoc=CC=8Cil?= Date: Tue, 28 Feb 2012 18:06:21 +0100 Subject: [PATCH] Do not assume UTF-8. --- httpie/httpie.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/httpie/httpie.py b/httpie/httpie.py index 793aecf6..ab20312a 100755 --- a/httpie/httpie.py +++ b/httpie/httpie.py @@ -27,10 +27,9 @@ class KeyValueType(object): self.separators = separators def __call__(self, string): - found = dict( - (string.find(sep), sep) for sep in self.separators - if string.find(sep) != -1 - ) + found = dict((string.find(sep), sep) + for sep in self.separators + if string.find(sep) != -1) if not found: raise argparse.ArgumentTypeError( @@ -155,14 +154,15 @@ def main(): sys.exit(1) # Display the response. + encoding = response.encoding or 'ISO-8859-1' original = response.raw._original_response status_line, headers, body = ( u'HTTP/{version} {status} {reason}'.format( version='.'.join(str(original.version)), status=original.status, reason=original.reason, ), - str(original.msg).decode('utf-8'), - response.content.decode('utf-8') if response.content else u'' + str(original.msg).decode(encoding), + response.content.decode(encoding) if response.content else u'' ) if args.prettify and sys.stdout.isatty():