mirror of
https://github.com/httpie/cli.git
synced 2025-06-13 00:07:26 +02:00
Fixed --form
file upload mixed with redirected stdin
error handling.
Close #840
This commit is contained in:
parent
6e9cd139a6
commit
e6bad645ed
@ -6,6 +6,11 @@ This document records all notable changes to `HTTPie <https://httpie.org>`_.
|
|||||||
This project adheres to `Semantic Versioning <https://semver.org/>`_.
|
This project adheres to `Semantic Versioning <https://semver.org/>`_.
|
||||||
|
|
||||||
|
|
||||||
|
`2.1.0-dev`_ (unreleased)
|
||||||
|
-------------------------
|
||||||
|
* Fixed ``--form`` file upload mixed with redirected ``stdin`` error handling.
|
||||||
|
|
||||||
|
|
||||||
`2.0.0`_ (2020-01-12)
|
`2.0.0`_ (2020-01-12)
|
||||||
-------------------------
|
-------------------------
|
||||||
* Removed Python 2.7 support (`EOL Jan 2020 <https://www.python.org/doc/sunset-python-2/>`_).
|
* Removed Python 2.7 support (`EOL Jan 2020 <https://www.python.org/doc/sunset-python-2/>`_).
|
||||||
|
@ -3,6 +3,6 @@ HTTPie - a CLI, cURL-like tool for humans.
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__version__ = '2.0.0'
|
__version__ = '2.1.0-dev'
|
||||||
__author__ = 'Jakub Roztocil'
|
__author__ = 'Jakub Roztocil'
|
||||||
__licence__ = 'BSD'
|
__licence__ = 'BSD'
|
||||||
|
@ -246,7 +246,8 @@ class HTTPieArgumentParser(argparse.ArgumentParser):
|
|||||||
if self.args.data:
|
if self.args.data:
|
||||||
self.error('Request body (from stdin or a file) and request '
|
self.error('Request body (from stdin or a file) and request '
|
||||||
'data (key=value) cannot be mixed. Pass '
|
'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()
|
self.args.data = getattr(fd, 'buffer', fd).read()
|
||||||
|
|
||||||
def _guess_method(self):
|
def _guess_method(self):
|
||||||
|
@ -98,6 +98,27 @@ def test_POST_file(httpbin_both):
|
|||||||
assert FILE_CONTENT in r
|
assert FILE_CONTENT in r
|
||||||
|
|
||||||
|
|
||||||
|
def test_form_POST_file_redirected_stdin(httpbin):
|
||||||
|
"""
|
||||||
|
<https://github.com/jakubroztocil/httpie/issues/840>
|
||||||
|
|
||||||
|
"""
|
||||||
|
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):
|
def test_headers(httpbin_both):
|
||||||
r = http('GET', httpbin_both + '/headers', 'Foo:bar')
|
r = http('GET', httpbin_both + '/headers', 'Foo:bar')
|
||||||
assert HTTP_OK in r
|
assert HTTP_OK in r
|
||||||
|
@ -3,6 +3,7 @@ import os
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from httpie.cli.exceptions import ParseError
|
from httpie.cli.exceptions import ParseError
|
||||||
|
from httpie.status import ExitStatus
|
||||||
from utils import MockEnvironment, http, HTTP_OK
|
from utils import MockEnvironment, http, HTTP_OK
|
||||||
from fixtures import FILE_PATH_ARG, FILE_PATH, FILE_CONTENT
|
from fixtures import FILE_PATH_ARG, FILE_PATH, FILE_CONTENT
|
||||||
|
|
||||||
@ -77,4 +78,5 @@ class TestRequestBodyFromFilePath:
|
|||||||
env=env,
|
env=env,
|
||||||
tolerate_error_exit_status=True,
|
tolerate_error_exit_status=True,
|
||||||
)
|
)
|
||||||
|
assert r.exit_status == ExitStatus.ERROR
|
||||||
assert 'cannot be mixed' in r.stderr
|
assert 'cannot be mixed' in r.stderr
|
||||||
|
Loading…
x
Reference in New Issue
Block a user