mirror of
https://github.com/httpie/cli.git
synced 2025-02-16 17:40:51 +01:00
Add --follow
test for HTTP 308
This commit is contained in:
parent
3228e74df5
commit
7ceb313ccf
@ -7,6 +7,10 @@ from .utils import http, HTTP_OK
|
|||||||
from .utils.matching import assert_output_matches, Expect, ExpectSequence
|
from .utils.matching import assert_output_matches, Expect, ExpectSequence
|
||||||
|
|
||||||
|
|
||||||
|
# <https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections>
|
||||||
|
REDIRECTS_WITH_METHOD_BODY_PRESERVED = [307, 308]
|
||||||
|
|
||||||
|
|
||||||
def test_follow_all_redirects_shown(httpbin):
|
def test_follow_all_redirects_shown(httpbin):
|
||||||
r = http('--follow', '--all', httpbin.url + '/redirect/2')
|
r = http('--follow', '--all', httpbin.url + '/redirect/2')
|
||||||
assert r.count('HTTP/1.1') == 3
|
assert r.count('HTTP/1.1') == 3
|
||||||
@ -37,6 +41,7 @@ def test_follow_all_output_options_used_for_redirects(httpbin):
|
|||||||
assert r.count('GET /') == 3
|
assert r.count('GET /') == 3
|
||||||
assert HTTP_OK not in r
|
assert HTTP_OK not in r
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# def test_follow_redirect_output_options(httpbin):
|
# def test_follow_redirect_output_options(httpbin):
|
||||||
# r = http('--check-status',
|
# r = http('--check-status',
|
||||||
@ -61,16 +66,21 @@ def test_max_redirects(httpbin):
|
|||||||
assert r.exit_status == ExitStatus.ERROR_TOO_MANY_REDIRECTS
|
assert r.exit_status == ExitStatus.ERROR_TOO_MANY_REDIRECTS
|
||||||
|
|
||||||
|
|
||||||
def test_http_307_allow_redirect_post(httpbin):
|
@pytest.mark.parametrize('status_code', REDIRECTS_WITH_METHOD_BODY_PRESERVED)
|
||||||
r = http('--follow', 'POST', httpbin.url + '/redirect-to',
|
def test_follow_redirect_with_repost(httpbin, status_code):
|
||||||
f'url=={httpbin.url}/post', 'status_code==307',
|
r = http(
|
||||||
'@' + FILE_PATH_ARG)
|
'--follow',
|
||||||
|
httpbin.url + '/redirect-to',
|
||||||
|
f'url=={httpbin.url}/post',
|
||||||
|
f'status_code=={status_code}',
|
||||||
|
'@' + FILE_PATH_ARG,
|
||||||
|
)
|
||||||
assert HTTP_OK in r
|
assert HTTP_OK in r
|
||||||
|
assert FILE_CONTENT in r
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('status_code', [307, 308])
|
@pytest.mark.parametrize('status_code', REDIRECTS_WITH_METHOD_BODY_PRESERVED)
|
||||||
def test_verbose_follow_redirect_with_repost(httpbin, status_code):
|
def test_verbose_follow_redirect_with_repost(httpbin, status_code):
|
||||||
# <https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections>
|
|
||||||
r = http(
|
r = http(
|
||||||
'--follow',
|
'--follow',
|
||||||
'--verbose',
|
'--verbose',
|
||||||
|
Loading…
Reference in New Issue
Block a user