mirror of
https://github.com/httpie/cli.git
synced 2024-12-27 08:48:58 +01:00
parent
af873effb6
commit
b0effe07d9
@ -1280,6 +1280,7 @@ Changelog
|
|||||||
* To make it easier to deal with Windows paths in request items, ``\``
|
* To make it easier to deal with Windows paths in request items, ``\``
|
||||||
now only escapes special characters (the ones that are used as key-value
|
now only escapes special characters (the ones that are used as key-value
|
||||||
separators).
|
separators).
|
||||||
|
* Fixed ``--output=/dev/null`` on Linux.
|
||||||
* `0.8.0`_ (2014-01-25)
|
* `0.8.0`_ (2014-01-25)
|
||||||
* Added ``field=@file.txt`` and ``field:=@file.json`` for embedding
|
* Added ``field=@file.txt`` and ``field:=@file.json`` for embedding
|
||||||
the contents of text and JSON files into request data.
|
the contents of text and JSON files into request data.
|
||||||
|
@ -5,6 +5,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
|
import errno
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import getpass
|
import getpass
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
@ -185,7 +186,14 @@ class Parser(ArgumentParser):
|
|||||||
# `stdout`. The file is opened for appending, which isn't what
|
# `stdout`. The file is opened for appending, which isn't what
|
||||||
# we want in this case.
|
# we want in this case.
|
||||||
self.args.output_file.seek(0)
|
self.args.output_file.seek(0)
|
||||||
|
try:
|
||||||
self.args.output_file.truncate()
|
self.args.output_file.truncate()
|
||||||
|
except IOError as e:
|
||||||
|
if e.errno == errno.EINVAL:
|
||||||
|
# E.g. /dev/null on Linux.
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
raise
|
||||||
self.env.stdout = self.args.output_file
|
self.env.stdout = self.args.output_file
|
||||||
self.env.stdout_isatty = False
|
self.env.stdout_isatty = False
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
"""Miscellaneous regression tests"""
|
"""Miscellaneous regression tests"""
|
||||||
|
import pytest
|
||||||
|
|
||||||
from utils import http, HTTP_OK
|
from utils import http, HTTP_OK
|
||||||
|
from httpie.compat import is_windows
|
||||||
|
|
||||||
|
|
||||||
def test_Host_header_overwrite(httpbin):
|
def test_Host_header_overwrite(httpbin):
|
||||||
@ -14,3 +16,12 @@ def test_Host_header_overwrite(httpbin):
|
|||||||
assert HTTP_OK in r
|
assert HTTP_OK in r
|
||||||
assert r.lower().count('host:') == 1
|
assert r.lower().count('host:') == 1
|
||||||
assert 'host: {0}'.format(host) in r
|
assert 'host: {0}'.format(host) in r
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif(is_windows, reason='Unix-only')
|
||||||
|
def test_output_devnull(httpbin):
|
||||||
|
"""
|
||||||
|
https://github.com/jakubroztocil/httpie/issues/252
|
||||||
|
|
||||||
|
"""
|
||||||
|
http('--output=/dev/null', httpbin + '/get')
|
||||||
|
Loading…
Reference in New Issue
Block a user