forked from extern/httpie-cli
parent
8c892edd4f
commit
040d981f00
@ -102,8 +102,7 @@ class HTTPRequest(HTTPMessage):
|
||||
)
|
||||
|
||||
headers = dict(self._orig.headers)
|
||||
|
||||
if 'Host' not in headers:
|
||||
if 'Host' not in self._orig.headers:
|
||||
headers['Host'] = url.netloc.split('@')[-1]
|
||||
|
||||
headers = ['%s: %s' % (name, value)
|
||||
|
17
tests/test_regressions.py
Normal file
17
tests/test_regressions.py
Normal file
@ -0,0 +1,17 @@
|
||||
"""Miscellaneous regression tests"""
|
||||
import socket
|
||||
|
||||
from utils import http, HTTP_OK
|
||||
|
||||
|
||||
def test_Host_header_overwrite():
|
||||
"""
|
||||
https://github.com/jakubroztocil/httpie/issues/235
|
||||
|
||||
"""
|
||||
host = 'httpbin.org'
|
||||
url = 'http://{httpbin_ip}/get'.format(
|
||||
httpbin_ip=socket.gethostbyname(host))
|
||||
r = http('--print=hH', url, 'host:{}'.format(host))
|
||||
assert HTTP_OK in r
|
||||
assert r.lower().count('host:') == 1
|
Loading…
Reference in New Issue
Block a user