2014-06-28 13:24:14 +02:00
|
|
|
"""Miscellaneous regression tests"""
|
2014-09-07 10:20:32 +02:00
|
|
|
import pytest
|
2014-06-28 13:24:14 +02:00
|
|
|
|
2014-09-07 10:20:32 +02:00
|
|
|
from httpie.compat import is_windows
|
2021-05-05 14:13:39 +02:00
|
|
|
from .utils.matching import assert_output_matches, Expect
|
|
|
|
from .utils import HTTP_OK, MockEnvironment, http
|
2014-06-28 13:24:14 +02:00
|
|
|
|
|
|
|
|
2014-06-28 16:35:57 +02:00
|
|
|
def test_Host_header_overwrite(httpbin):
|
2014-06-28 13:24:14 +02:00
|
|
|
"""
|
2023-08-06 14:04:32 +02:00
|
|
|
https://github.com/httpie/cli/issues/235
|
2014-06-28 13:24:14 +02:00
|
|
|
|
|
|
|
"""
|
2020-12-24 21:34:30 +01:00
|
|
|
host = 'pie.dev'
|
2016-10-26 11:28:17 +02:00
|
|
|
url = httpbin.url + '/get'
|
2021-05-26 14:09:38 +02:00
|
|
|
r = http('--print=hH', url, f'host:{host}')
|
2014-06-28 13:24:14 +02:00
|
|
|
assert HTTP_OK in r
|
|
|
|
assert r.lower().count('host:') == 1
|
2021-05-26 14:09:38 +02:00
|
|
|
assert f'host: {host}' in r
|
2014-09-07 10:20:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.skipif(is_windows, reason='Unix-only')
|
|
|
|
def test_output_devnull(httpbin):
|
|
|
|
"""
|
2023-08-06 14:04:32 +02:00
|
|
|
https://github.com/httpie/cli/issues/252
|
2014-09-07 10:20:32 +02:00
|
|
|
|
|
|
|
"""
|
|
|
|
http('--output=/dev/null', httpbin + '/get')
|
2020-12-22 22:56:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_verbose_redirected_stdout_separator(httpbin):
|
|
|
|
"""
|
|
|
|
|
2023-08-06 14:04:32 +02:00
|
|
|
<https://github.com/httpie/cli/issues/1006>
|
2020-12-22 22:56:45 +01:00
|
|
|
"""
|
|
|
|
r = http(
|
|
|
|
'-v',
|
|
|
|
httpbin.url + '/post',
|
|
|
|
'a=b',
|
|
|
|
env=MockEnvironment(stdout_isatty=False),
|
|
|
|
)
|
|
|
|
assert '}HTTP/' not in r
|
2021-01-30 22:14:57 +01:00
|
|
|
assert_output_matches(r, [
|
|
|
|
Expect.REQUEST_HEADERS,
|
|
|
|
Expect.BODY,
|
|
|
|
Expect.SEPARATOR,
|
|
|
|
Expect.RESPONSE_HEADERS,
|
|
|
|
Expect.BODY,
|
|
|
|
])
|