forked from extern/httpie-cli
Allow stdin to be a closed fd #791
This commit is contained in:
parent
07da8ea852
commit
ced9212c1f
@ -7,7 +7,6 @@ env:
|
||||
global:
|
||||
- NEWEST_PYTHON=3.7
|
||||
python:
|
||||
- 3.5
|
||||
- 3.6
|
||||
# - 3.7 # is done in the matrix below as described in travis-ci/travis-ci#9069
|
||||
# pypy3 currently fails because of a Flask issue
|
||||
|
@ -14,6 +14,7 @@ This project adheres to `Semantic Versioning <http://semver.org/>`_.
|
||||
* Added ``--max-headers`` to allow setting the max header limit.
|
||||
* Added ``--compress``.
|
||||
* Added ``https`` alias command with ``https://`` as the default scheme.
|
||||
* Fixed an exception when ``stdin`` was a closed fd.
|
||||
|
||||
|
||||
`1.0.3`_ (2019-08-26)
|
||||
|
@ -126,7 +126,7 @@ and always provides the latest version) is to use `pip`_:
|
||||
Python version
|
||||
--------------
|
||||
|
||||
Starting with version 2.0.0 (currently under development) Python 3.5+ is required.
|
||||
Starting with version 2.0.0 (currently under development) Python 3.6+ is required.
|
||||
|
||||
|
||||
Unstable version
|
||||
|
@ -1,4 +1,7 @@
|
||||
import sys
|
||||
from typing import Union, IO, Optional
|
||||
|
||||
|
||||
try:
|
||||
import curses
|
||||
except ImportError:
|
||||
@ -22,7 +25,7 @@ class Environment(object):
|
||||
"""
|
||||
is_windows = is_windows
|
||||
config_dir = DEFAULT_CONFIG_DIR
|
||||
stdin = sys.stdin
|
||||
stdin: Optional[IO] = sys.stdin # `None` when closed fd (#791)
|
||||
stdin_isatty = stdin.isatty() if stdin else False
|
||||
stdin_encoding = None
|
||||
stdout = sys.stdout
|
||||
|
@ -134,6 +134,7 @@ class HTTPieArgumentParser(ArgumentParser):
|
||||
super(HTTPieArgumentParser, self).__init__(*args, **kwargs)
|
||||
self.env = None
|
||||
self.args = None
|
||||
self.has_stdin_data = False
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def parse_args(self, env, program_name='http', args=None, namespace=None):
|
||||
|
@ -310,7 +310,7 @@ class TestNoOptions:
|
||||
assert 'GET /get HTTP/1.1' not in r
|
||||
|
||||
|
||||
class TestIgnoreStdin:
|
||||
class TestStdin:
|
||||
|
||||
def test_ignore_stdin(self, httpbin):
|
||||
with open(FILE_PATH) as f:
|
||||
@ -327,6 +327,10 @@ class TestIgnoreStdin:
|
||||
assert r.exit_status == ExitStatus.ERROR
|
||||
assert 'because --ignore-stdin' in r.stderr
|
||||
|
||||
def test_stdin_closed(self, httpbin):
|
||||
r = http(httpbin + '/get', env=MockEnvironment(stdin=None))
|
||||
assert HTTP_OK in r
|
||||
|
||||
|
||||
class TestSchemes:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user