mirror of
https://github.com/httpie/cli.git
synced 2024-11-25 17:23:25 +01:00
Revert "Not all web servers return UTF-8 and will crash httpie when decoding the response"
This reverts commit 2f569b901d
.
This commit is contained in:
parent
2f569b901d
commit
6f9ad9e4e1
@ -163,22 +163,13 @@ def main():
|
|||||||
|
|
||||||
# Display the response.
|
# Display the response.
|
||||||
original = response.raw._original_response
|
original = response.raw._original_response
|
||||||
|
|
||||||
try:
|
|
||||||
decode_from = [
|
|
||||||
bit.split('=')[1] for bit in response.headers['content-type'].split(';')
|
|
||||||
if 'charset' in bit
|
|
||||||
][0]
|
|
||||||
except IndexError:
|
|
||||||
decode_from = 'utf-8'
|
|
||||||
|
|
||||||
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(decode_from),
|
str(original.msg).decode('utf-8'),
|
||||||
response.content.decode(decode_from) if response.content else u''
|
response.content.decode('utf-8') 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