You've already forked httpie-cli
mirror of
https://github.com/httpie/cli.git
synced 2025-08-10 22:42:05 +02:00
Implemented more robust unicode handling.
* Immediatelly convert all args from `bytes` to `str`. * Added `Environment.stdin_encoding` and `Environment.stdout_encoding` * Allow unicode characters in HTTP headers and basic auth credentials by encoding them using UTF8 instead of latin1 (#212).
This commit is contained in:
@@ -6,6 +6,7 @@ import requests
|
||||
|
||||
from . import sessions
|
||||
from . import __version__
|
||||
from .compat import str
|
||||
from .plugins import plugin_manager
|
||||
|
||||
|
||||
@@ -79,11 +80,18 @@ def get_requests_kwargs(args):
|
||||
if args.certkey:
|
||||
cert = (cert, args.certkey)
|
||||
|
||||
# This allows for unicode headers which is non-standard but practical.
|
||||
# See: https://github.com/jkbr/httpie/issues/212
|
||||
headers = dict(
|
||||
(k.encode('utf8'), v.encode('utf8') if isinstance(v, str) else v)
|
||||
for k, v in args.headers.items()
|
||||
)
|
||||
|
||||
kwargs = {
|
||||
'stream': True,
|
||||
'method': args.method.lower(),
|
||||
'url': args.url,
|
||||
'headers': args.headers,
|
||||
'headers': headers,
|
||||
'data': args.data,
|
||||
'verify': {
|
||||
'yes': True,
|
||||
|
Reference in New Issue
Block a user