1
0
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:
Batuhan Taskaya
2022-04-03 16:02:41 +03:00
committed by GitHub
parent d1596dde12
commit 33ea977b64
5 changed files with 71 additions and 5 deletions

View File

@@ -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