diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2776c3f9..293a32df 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,11 @@ This document records all notable changes to `HTTPie `_. This project adheres to `Semantic Versioning `_. +`2.1.0-dev`_ (unreleased) +------------------------- +* Fixed ``--form`` file upload mixed with redirected ``stdin`` error handling. + + `2.0.0`_ (2020-01-12) ------------------------- * Removed Python 2.7 support (`EOL Jan 2020 `_). diff --git a/httpie/__init__.py b/httpie/__init__.py index c5f7ac47..eee945f8 100644 --- a/httpie/__init__.py +++ b/httpie/__init__.py @@ -3,6 +3,6 @@ HTTPie - a CLI, cURL-like tool for humans. """ -__version__ = '2.0.0' +__version__ = '2.1.0-dev' __author__ = 'Jakub Roztocil' __licence__ = 'BSD' diff --git a/httpie/cli/argparser.py b/httpie/cli/argparser.py index 4924552e..cf096d8d 100644 --- a/httpie/cli/argparser.py +++ b/httpie/cli/argparser.py @@ -246,7 +246,8 @@ class HTTPieArgumentParser(argparse.ArgumentParser): if self.args.data: self.error('Request body (from stdin or a file) and request ' 'data (key=value) cannot be mixed. Pass ' - '--ignore-stdin to let key/value take priority.') + '--ignore-stdin to let key/value take priority. ' + 'See https://httpie.org/doc#scripting for details.') self.args.data = getattr(fd, 'buffer', fd).read() def _guess_method(self): diff --git a/tests/test_httpie.py b/tests/test_httpie.py index 252b0a17..70bc2f9d 100644 --- a/tests/test_httpie.py +++ b/tests/test_httpie.py @@ -98,6 +98,27 @@ def test_POST_file(httpbin_both): assert FILE_CONTENT in r +def test_form_POST_file_redirected_stdin(httpbin): + """ + + + """ + with open(FILE_PATH) as f: + r = http( + '--form', + 'POST', + httpbin + '/post', + 'file@' + FILE_PATH, + tolerate_error_exit_status=True, + env=MockEnvironment( + stdin=f, + stdin_isatty=False, + ), + ) + assert r.exit_status == ExitStatus.ERROR + assert 'cannot be mixed' in r.stderr + + def test_headers(httpbin_both): r = http('GET', httpbin_both + '/headers', 'Foo:bar') assert HTTP_OK in r diff --git a/tests/test_uploads.py b/tests/test_uploads.py index 81298fa5..b0c7fc5d 100644 --- a/tests/test_uploads.py +++ b/tests/test_uploads.py @@ -3,6 +3,7 @@ import os import pytest from httpie.cli.exceptions import ParseError +from httpie.status import ExitStatus from utils import MockEnvironment, http, HTTP_OK from fixtures import FILE_PATH_ARG, FILE_PATH, FILE_CONTENT @@ -77,4 +78,5 @@ class TestRequestBodyFromFilePath: env=env, tolerate_error_exit_status=True, ) + assert r.exit_status == ExitStatus.ERROR assert 'cannot be mixed' in r.stderr