Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Commit bb62f80

Browse files
committed
Enable override default headers from CLI
1 parent 6be7831 commit bb62f80

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

hyper/cli.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,12 @@ def set_request_data(args):
164164
body, headers, params = {}, {}, {}
165165
for i in args.items:
166166
if i.sep == SEP_HEADERS:
167-
headers[i.key] = i.value
167+
# :key:value case
168+
if i.key == '':
169+
k, v = i.value.split(':')
170+
headers[':' + k] = v
171+
else:
172+
headers[i.key] = i.value
168173
elif i.sep == SEP_QUERY:
169174
params[i.key] = i.value
170175
elif i.sep == SEP_DATA:

test/test_cli.py

+9
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,20 @@ def test_cli_with_system_exit(argv):
110110
{'method': 'GET', 'url.path': '/?param=test'}),
111111
(['POST', 'example.com', 'data=test'],
112112
{'method': 'POST', 'body': '{"data": "test"}'}),
113+
(['GET', 'example.com', ':authority:example.org'],
114+
{'method': 'GET', 'headers': {
115+
':authority': 'example.org'}}),
116+
(['GET', 'example.com', ':authority:example.org', 'x-test:header'],
117+
{'method': 'GET', 'headers': {
118+
':authority': 'example.org',
119+
'x-test':'header'}}),
113120
], ids=[
114121
'specified "--debug" option',
115122
'specified host and additional header',
116123
'specified host and get parameter',
117124
'specified host and post data',
125+
'specified host and override default header',
126+
'specified host and override default header and additional header',
118127
])
119128
def test_parse_argument(argv, expected):
120129
args = parse_argument(argv)

0 commit comments

Comments
 (0)