mirror of
https://github.com/httpie/cli.git
synced 2024-11-21 23:33:12 +01:00
parent
0f1e098cc4
commit
cf78a12e46
@ -9,7 +9,7 @@ This project adheres to `Semantic Versioning <https://semver.org/>`_.
|
||||
|
||||
`2.4.0-dev`_ (unreleased)
|
||||
-------------------------
|
||||
|
||||
* Show a ``--check-status`` warning with ``--quiet`` as well, not only when the output si redirected. (`#1026`_)
|
||||
* Fixed upload with ``--session`` (`#1020`_).
|
||||
* Fixed a missing blank line between request and response (`#1006`_).
|
||||
|
||||
@ -488,3 +488,4 @@ This project adheres to `Semantic Versioning <https://semver.org/>`_.
|
||||
.. _#963: https://github.com/httpie/httpie/issues/963
|
||||
.. _#1006: https://github.com/httpie/httpie/issues/1006
|
||||
.. _#1020: https://github.com/httpie/httpie/issues/1020
|
||||
.. _#1026: https://github.com/httpie/httpie/issues/1026
|
||||
|
@ -1292,7 +1292,7 @@ Quiet output
|
||||
------------
|
||||
|
||||
``--quiet`` redirects all output that would otherwise go to ``stdout``
|
||||
and ``stderr`` (except for error messages) to ``/dev/null``.
|
||||
and ``stderr`` to ``/dev/null`` (except for errors and warnings).
|
||||
This doesn’t affect output to a file via ``--output`` or ``--download``.
|
||||
|
||||
.. code-block:: bash
|
||||
|
@ -185,7 +185,7 @@ def program(args: argparse.Namespace, env: Environment) -> ExitStatus:
|
||||
final_response = message
|
||||
if args.check_status or downloader:
|
||||
exit_status = http_status_to_exit_status(http_status=message.status_code, follow=args.follow)
|
||||
if not env.stdout_isatty and exit_status != ExitStatus.SUCCESS:
|
||||
if exit_status != ExitStatus.SUCCESS and (not env.stdout_isatty or args.quiet):
|
||||
env.log_error(f'HTTP {message.raw.status} {message.raw.reason}', level='warning')
|
||||
write_message(requests_message=message, env=env, args=args, with_headers=with_headers,
|
||||
with_body=do_write_body)
|
||||
|
@ -54,6 +54,21 @@ class TestQuietFlag:
|
||||
assert r == ''
|
||||
assert r.stderr == ''
|
||||
|
||||
def test_quiet_with_check_status_non_zero(self, httpbin):
|
||||
r = http(
|
||||
'--quiet', '--check-status', httpbin + '/status/500',
|
||||
tolerate_error_exit_status=True,
|
||||
)
|
||||
assert 'http: warning: HTTP 500' in r.stderr
|
||||
|
||||
def test_quiet_with_check_status_non_zero_pipe(self, httpbin):
|
||||
r = http(
|
||||
'--quiet', '--check-status', httpbin + '/status/500',
|
||||
tolerate_error_exit_status=True,
|
||||
env=MockEnvironment(stdout_isatty=False)
|
||||
)
|
||||
assert 'http: warning: HTTP 500' in r.stderr
|
||||
|
||||
@mock.patch('httpie.cli.argtypes.AuthCredentials._getpass',
|
||||
new=lambda self, prompt: 'password')
|
||||
def test_quiet_with_password_prompt(self, httpbin):
|
||||
|
Loading…
Reference in New Issue
Block a user