mirror of
https://github.com/httpie/cli.git
synced 2024-11-21 23:33:12 +01:00
Do not assume UTF-8.
This commit is contained in:
parent
f90ae113e4
commit
0293ba1799
@ -27,10 +27,9 @@ class KeyValueType(object):
|
|||||||
self.separators = separators
|
self.separators = separators
|
||||||
|
|
||||||
def __call__(self, string):
|
def __call__(self, string):
|
||||||
found = dict(
|
found = dict((string.find(sep), sep)
|
||||||
(string.find(sep), sep) for sep in self.separators
|
for sep in self.separators
|
||||||
if string.find(sep) != -1
|
if string.find(sep) != -1)
|
||||||
)
|
|
||||||
|
|
||||||
if not found:
|
if not found:
|
||||||
raise argparse.ArgumentTypeError(
|
raise argparse.ArgumentTypeError(
|
||||||
@ -155,14 +154,15 @@ def main():
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Display the response.
|
# Display the response.
|
||||||
|
encoding = response.encoding or 'ISO-8859-1'
|
||||||
original = response.raw._original_response
|
original = response.raw._original_response
|
||||||
status_line, headers, body = (
|
status_line, headers, body = (
|
||||||
u'HTTP/{version} {status} {reason}'.format(
|
u'HTTP/{version} {status} {reason}'.format(
|
||||||
version='.'.join(str(original.version)),
|
version='.'.join(str(original.version)),
|
||||||
status=original.status, reason=original.reason,
|
status=original.status, reason=original.reason,
|
||||||
),
|
),
|
||||||
str(original.msg).decode('utf-8'),
|
str(original.msg).decode(encoding),
|
||||||
response.content.decode('utf-8') if response.content else u''
|
response.content.decode(encoding) if response.content else u''
|
||||||
)
|
)
|
||||||
|
|
||||||
if args.prettify and sys.stdout.isatty():
|
if args.prettify and sys.stdout.isatty():
|
||||||
|
Loading…
Reference in New Issue
Block a user