mirror of
https://github.com/httpie/cli.git
synced 2025-06-20 09:37:45 +02:00
Decode headers using utf-8 only if they are not str (#1020)
This commit is contained in:
parent
44ae67685d
commit
db685d58b5
@ -77,7 +77,9 @@ class Session(BaseConfigDict):
|
|||||||
if value is None:
|
if value is None:
|
||||||
continue # Ignore explicitly unset headers
|
continue # Ignore explicitly unset headers
|
||||||
|
|
||||||
|
if type(value) is not str:
|
||||||
value = value.decode('utf8')
|
value = value.decode('utf8')
|
||||||
|
|
||||||
if name.lower() == 'user-agent' and value.startswith('HTTPie/'):
|
if name.lower() == 'user-agent' and value.startswith('HTTPie/'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ from httpie.sessions import Session
|
|||||||
from httpie.utils import get_expired_cookies
|
from httpie.utils import get_expired_cookies
|
||||||
from tests.test_auth_plugins import basic_auth
|
from tests.test_auth_plugins import basic_auth
|
||||||
from utils import HTTP_OK, MockEnvironment, http, mk_config_dir
|
from utils import HTTP_OK, MockEnvironment, http, mk_config_dir
|
||||||
|
from fixtures import FILE_PATH_ARG
|
||||||
|
|
||||||
|
|
||||||
class SessionTestBase:
|
class SessionTestBase:
|
||||||
@ -161,6 +162,12 @@ class TestSession(SessionTestBase):
|
|||||||
assert 'Content-Type' not in r2.json['headers']
|
assert 'Content-Type' not in r2.json['headers']
|
||||||
assert 'If-Unmodified-Since' not in r2.json['headers']
|
assert 'If-Unmodified-Since' not in r2.json['headers']
|
||||||
|
|
||||||
|
def test_session_with_upload(self, httpbin):
|
||||||
|
self.start_session(httpbin)
|
||||||
|
r = http('--session=test', '--form', '--verbose', 'POST', httpbin.url + '/post',
|
||||||
|
f'test-file@{FILE_PATH_ARG}', 'foo=bar', env=self.env())
|
||||||
|
assert HTTP_OK in r
|
||||||
|
|
||||||
def test_session_by_path(self, httpbin):
|
def test_session_by_path(self, httpbin):
|
||||||
self.start_session(httpbin)
|
self.start_session(httpbin)
|
||||||
session_path = self.config_dir / 'session-by-path.json'
|
session_path = self.config_dir / 'session-by-path.json'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user