1
0
mirror of https://github.com/httpie/cli.git synced 2024-11-24 08:22:22 +02:00

Do not assume UTF-8.

This commit is contained in:
Jakub Roztočil 2012-02-28 18:06:21 +01:00
parent f90ae113e4
commit 0293ba1799

View File

@ -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():