Fixed --download with --session

Closes #412
This commit is contained in:
Jakub Roztocil 2016-02-28 19:14:10 +08:00
parent 8c33e5e3d3
commit 5898879395
2 changed files with 16 additions and 0 deletions

View File

@ -101,6 +101,10 @@ class Session(BaseConfigDict):
"""
for name, value in request_headers.items():
if value is None:
continue # Ignore explicitely unset headers
value = value.decode('utf8')
if name == 'User-Agent' and value.startswith('HTTPie/'):
continue

View File

@ -2,6 +2,7 @@
import os
import shutil
import sys
from tempfile import gettempdir
import pytest
@ -174,3 +175,14 @@ class TestSession(SessionTestBase):
r2 = http('--session=test', httpbin.url + '/headers', env=self.env())
assert HTTP_OK in r2
assert r2.json['headers']['User-Agent'] == 'custom'
def test_download_in_session(self, httpbin):
# https://github.com/jkbrzt/httpie/issues/412
self.start_session(httpbin)
cwd = os.getcwd()
try:
os.chdir(gettempdir())
http('--session=test', '--download',
httpbin.url + '/get', env=self.env())
finally:
os.chdir(cwd)