You've already forked httpie-cli
mirror of
https://github.com/httpie/cli.git
synced 2025-08-10 22:42:05 +02:00
Don't send Content-Length
for OPTIONS
requests when there is no data. (#1319)
This commit is contained in:
@@ -324,3 +324,41 @@ def test_json_input_preserve_order(httpbin_both):
|
||||
assert HTTP_OK in r
|
||||
assert r.json['data'] == \
|
||||
'{"order": {"map": {"1": "first", "2": "second"}}}'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('extra_args, expected_content_length', [
|
||||
(
|
||||
['Content-Length:0'],
|
||||
'0'
|
||||
),
|
||||
(
|
||||
['Content-Length:xxx'],
|
||||
'xxx',
|
||||
),
|
||||
(
|
||||
['--raw=data'],
|
||||
'4'
|
||||
),
|
||||
(
|
||||
['query[param]=something'],
|
||||
'33'
|
||||
)
|
||||
])
|
||||
def test_options_content_length_preservation(httpbin, extra_args, expected_content_length):
|
||||
r = http(
|
||||
'--offline',
|
||||
'OPTIONS',
|
||||
httpbin + '/anything',
|
||||
*extra_args
|
||||
)
|
||||
assert f'Content-Length: {expected_content_length}' in r
|
||||
|
||||
|
||||
@pytest.mark.parametrize('method', ['options', 'Options', 'OPTIONS'])
|
||||
def test_options_dropping_redundant_content_length(httpbin, method):
|
||||
r = http(
|
||||
'--offline',
|
||||
method,
|
||||
httpbin + '/anything'
|
||||
)
|
||||
assert 'Content-Length' not in r
|
||||
|
Reference in New Issue
Block a user