Fix printing redirected prepared request in verbose mode (#1088)

This commit is contained in:
Mickaël Schoentgen 2021-06-15 13:39:46 +02:00 committed by GitHub
parent 1470ca0c77
commit 2d55c01c7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 3 deletions

View File

@ -177,10 +177,10 @@ def program(args: argparse.Namespace, env: Environment) -> ExitStatus:
if is_request: if is_request:
if not initial_request: if not initial_request:
initial_request = message initial_request = message
if with_body:
is_streamed_upload = not isinstance(message.body, (str, bytes)) is_streamed_upload = not isinstance(message.body, (str, bytes))
if with_body: do_write_body = not is_streamed_upload
do_write_body = not is_streamed_upload force_separator = is_streamed_upload and env.stdout_isatty
force_separator = is_streamed_upload and env.stdout_isatty
else: else:
final_response = message final_response = message
if args.check_status or downloader: if args.check_status or downloader:

View File

@ -2,6 +2,7 @@
import pytest import pytest
from httpie.status import ExitStatus from httpie.status import ExitStatus
from .fixtures import FILE_PATH_ARG
from .utils import http, HTTP_OK from .utils import http, HTTP_OK
@ -57,3 +58,19 @@ def test_max_redirects(httpbin):
tolerate_error_exit_status=True, tolerate_error_exit_status=True,
) )
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):
r = http('--follow', 'POST', httpbin.url + '/redirect-to',
f'url=={httpbin.url}/post', 'status_code==307',
'@' + FILE_PATH_ARG)
assert HTTP_OK in r
def test_http_307_allow_redirect_post_verbose(httpbin):
r = http('--follow', '--verbose', 'POST', httpbin.url + '/redirect-to',
f'url=={httpbin.url}/post', 'status_code==307',
'@' + FILE_PATH_ARG)
assert r.count('POST /redirect-to') == 1
assert r.count('POST /post') == 1
assert HTTP_OK in r