mirror of
https://github.com/httpie/cli.git
synced 2025-08-14 13:39:18 +02:00
Compare commits
95 Commits
Author | SHA1 | Date | |
---|---|---|---|
4722076335 | |||
f14a0ad37d | |||
4cadc1d4c0 | |||
c3e5456aba | |||
33489c9a91 | |||
4e2b6b0ccc | |||
b034c8703a | |||
ab3d2656af | |||
c42bd0051a | |||
288cb4fdeb | |||
8771d759fe | |||
2cdca36960 | |||
8dc4f04fda | |||
dadc0cd27c | |||
59fd42244a | |||
6afe9c32c4 | |||
cc0ba03290 | |||
fad84a962e | |||
4f755a8bde | |||
21ee981fc6 | |||
45df860124 | |||
277da1ff93 | |||
1ded5c2a97 | |||
69bd72ce95 | |||
8bf6db471b | |||
b1cc069fce | |||
ed484c278b | |||
aec0f04f5d | |||
8eb460a6f3 | |||
5fe5958b06 | |||
0e1c17daa1 | |||
307517e7ef | |||
d60a04da2d | |||
9ea89ffefe | |||
bebeb2100d | |||
2b51cb6687 | |||
fa4bd033ef | |||
f8c1104429 | |||
be9d9281b7 | |||
ced0838598 | |||
d8b819b03f | |||
6fd0f23f39 | |||
483546d781 | |||
daf3573908 | |||
62407f781f | |||
cbbaac13ea | |||
6aad79d71c | |||
c1f26347fc | |||
29a0147dd5 | |||
ab0d1fd8d0 | |||
35a3dd2855 | |||
ece85c0f0c | |||
798cd4f0ec | |||
1a43c0e5f7 | |||
fdabbc6048 | |||
5f3de558cb | |||
fdae686e12 | |||
1c181a5d25 | |||
a228399801 | |||
bada3b45f1 | |||
e4bc363f9e | |||
24957e3b61 | |||
fb437591da | |||
b7fc89acdc | |||
2e88aa53cf | |||
9e62151bec | |||
ecc59591f1 | |||
f855de16c2 | |||
7f8adad313 | |||
51c19cfe10 | |||
dd7f1c4cce | |||
45784c7260 | |||
868baaba4e | |||
5760b780a0 | |||
2e5d14238f | |||
3b3eff01b7 | |||
42f454eb6b | |||
40d95b650c | |||
bc0d17c04c | |||
985f65ef52 | |||
dd0a4ab87a | |||
07aaefa232 | |||
419ca85e62 | |||
596fdc8c7e | |||
6e7e2f2eea | |||
748794257c | |||
55fa975ae5 | |||
e6e94398ae | |||
fbd44640e6 | |||
43915b5fc0 | |||
f1e1299104 | |||
86ebb9b741 | |||
873102d5eb | |||
337c05f95c | |||
a786f17997 |
17
.editorconfig
Normal file
17
.editorconfig
Normal file
@ -0,0 +1,17 @@
|
||||
# http://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.yml]
|
||||
indent_size = 2
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
indent_size = 8
|
11
.travis.yml
11
.travis.yml
@ -1,7 +1,11 @@
|
||||
# https://travis-ci.org/jakubroztocil/httpie
|
||||
# https://travis-ci.org/jkbrzt/httpie
|
||||
sudo: false
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
# - osx
|
||||
env:
|
||||
global:
|
||||
- NEWEST_PYTHON=3.4
|
||||
language: python
|
||||
python:
|
||||
- 2.6
|
||||
@ -13,5 +17,4 @@ python:
|
||||
script:
|
||||
- make
|
||||
after_success:
|
||||
- pip install python-coveralls
|
||||
- coveralls
|
||||
- if [[ $TRAVIS_PYTHON_VERSION == $NEWEST_PYTHON ]]; then pip install python-coveralls && coveralls; fi
|
||||
|
@ -2,7 +2,7 @@
|
||||
HTTPie authors
|
||||
==============
|
||||
|
||||
* `Jakub Roztocil <https://github.com/jakubroztocil>`_
|
||||
* `Jakub Roztocil <https://github.com/jkbrzt>`_
|
||||
|
||||
|
||||
Patches and ideas
|
||||
@ -32,3 +32,5 @@ Patches and ideas
|
||||
* `Nathan LaFreniere <https://github.com/nlf>`_
|
||||
* `Matthias Lehmann <https://github.com/matleh>`_
|
||||
* `Dennis Brakhane <https://github.com/brakhane>`_
|
||||
* `Matt Layman <https://github.com/mblayman>`_
|
||||
* `Edward Yang <https://github.com/honorabrutroll>`_
|
||||
|
260
CHANGELOG.rst
Normal file
260
CHANGELOG.rst
Normal file
@ -0,0 +1,260 @@
|
||||
==========
|
||||
Change Log
|
||||
==========
|
||||
|
||||
This document records all notable changes to `HTTPie <http://httpie.org>`_.
|
||||
This project adheres to `Semantic Versioning <http://semver.org/>`_.
|
||||
|
||||
|
||||
`0.9.3`_ (2016-01-01)
|
||||
-------------------------
|
||||
|
||||
* Changed the default color ``--style`` from ``solarized`` to ``monokai``
|
||||
* Added basic Bash autocomplete support (need to be installed manually)
|
||||
* Added request details to connection error messages
|
||||
* Fixed ``'requests.packages.urllib3' has no attribute 'disable_warnings'``
|
||||
errors that occurred in some installations
|
||||
* Fixed colors and formatting on Windows
|
||||
* Fixed ``--auth`` prompt on Windows
|
||||
|
||||
|
||||
`0.9.2`_ (2015-02-24)
|
||||
---------------------
|
||||
|
||||
* Fixed compatibility with Requests 2.5.1
|
||||
* Changed the default JSON ``Content-Type`` to ``application/json`` as UTF-8
|
||||
is the default JSON encoding
|
||||
|
||||
|
||||
`0.9.1`_ (2015-02-07)
|
||||
---------------------
|
||||
|
||||
* Added support for Requests transport adapter plugins
|
||||
(see `httpie-unixsocket <https://github.com/msabramo/httpie-unixsocket>`_
|
||||
and `httpie-http2 <https://github.com/jkbrzt/httpie-http2>`_)
|
||||
|
||||
|
||||
`0.9.0`_ (2015-01-31)
|
||||
---------------------
|
||||
|
||||
* Added ``--cert`` and ``--cert-key`` parameters to specify a client side
|
||||
certificate and private key for SSL
|
||||
* Improved unicode support
|
||||
* Improved terminal color depth detection via ``curses``
|
||||
* 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
|
||||
separators by HTTPie)
|
||||
* Switched from ``unittest`` to ``pytest``
|
||||
* Added Python `wheel` support
|
||||
* Various test suite improvements
|
||||
* Added ``CONTRIBUTING``
|
||||
* Fixed ``User-Agent`` overwriting when used within a session
|
||||
* Fixed handling of empty passwords in URL credentials
|
||||
* Fixed multiple file uploads with the same form field name
|
||||
* Fixed ``--output=/dev/null`` on Linux
|
||||
* Miscellaneous bugfixes
|
||||
|
||||
|
||||
`0.8.0`_ (2014-01-25)
|
||||
---------------------
|
||||
|
||||
* Added ``field=@file.txt`` and ``field:=@file.json`` for embedding
|
||||
the contents of text and JSON files into request data
|
||||
* Added curl-style shorthand for localhost
|
||||
* Fixed request ``Host`` header value output so that it doesn't contain
|
||||
credentials, if included in the URL
|
||||
|
||||
|
||||
`0.7.1`_ (2013-09-24)
|
||||
---------------------
|
||||
|
||||
* Added ``--ignore-stdin``
|
||||
* Added support for auth plugins
|
||||
* Improved ``--help`` output
|
||||
* Improved ``Content-Disposition`` parsing for ``--download`` mode
|
||||
* Update to Requests 2.0.0
|
||||
|
||||
|
||||
`0.6.0`_ (2013-06-03)
|
||||
---------------------
|
||||
|
||||
* XML data is now formatted
|
||||
* ``--session`` and ``--session-read-only`` now also accept paths to
|
||||
session files (eg. ``http --session=/tmp/session.json example.org``)
|
||||
|
||||
|
||||
`0.5.1`_ (2013-05-13)
|
||||
---------------------
|
||||
|
||||
* ``Content-*`` and ``If-*`` request headers are not stored in sessions
|
||||
anymore as they are request-specific
|
||||
|
||||
|
||||
`0.5.0`_ (2013-04-27)
|
||||
---------------------
|
||||
|
||||
* Added a download mode via ``--download``
|
||||
* Fixes miscellaneous bugs
|
||||
|
||||
|
||||
`0.4.1`_ (2013-02-26)
|
||||
---------------------
|
||||
|
||||
* Fixed ``setup.py``
|
||||
|
||||
|
||||
`0.4.0`_ (2013-02-22)
|
||||
---------------------
|
||||
|
||||
* Added Python 3.3 compatibility
|
||||
* Added Requests >= v1.0.4 compatibility
|
||||
* Added support for credentials in URL
|
||||
* Added ``--no-option`` for every ``--option`` to be config-friendly
|
||||
* Mutually exclusive arguments can be specified multiple times. The
|
||||
last value is used
|
||||
|
||||
|
||||
`0.3.0`_ (2012-09-21)
|
||||
---------------------
|
||||
|
||||
* Allow output redirection on Windows
|
||||
* Added configuration file
|
||||
* Added persistent session support
|
||||
* Renamed ``--allow-redirects`` to ``--follow``
|
||||
* Improved the usability of ``http --help``
|
||||
* Fixed installation on Windows with Python 3
|
||||
* Fixed colorized output on Windows with Python 3
|
||||
* CRLF HTTP header field separation in the output
|
||||
* Added exit status code ``2`` for timed-out requests
|
||||
* Added the option to separate colorizing and formatting
|
||||
(``--pretty=all``, ``--pretty=colors`` and ``--pretty=format``)
|
||||
``--ugly`` has bee removed in favor of ``--pretty=none``
|
||||
|
||||
|
||||
`0.2.7`_ (2012-08-07)
|
||||
---------------------
|
||||
|
||||
* Added compatibility with Requests 0.13.6
|
||||
* Added streamed terminal output. ``--stream, -S`` can be used to enable
|
||||
streaming also with ``--pretty`` and to ensure a more frequent output
|
||||
flushing
|
||||
* Added support for efficient large file downloads
|
||||
* Sort headers by name (unless ``--pretty=none``)
|
||||
* Response body is fetched only when needed (e.g., not with ``--headers``)
|
||||
* Improved content type matching
|
||||
* Updated Solarized color scheme
|
||||
* Windows: Added ``--output FILE`` to store output into a file
|
||||
(piping results in corrupted data on Windows)
|
||||
* Proper handling of binary requests and responses
|
||||
* Fixed printing of ``multipart/form-data`` requests
|
||||
* Renamed ``--traceback`` to ``--debug``
|
||||
|
||||
|
||||
`0.2.6`_ (2012-07-26)
|
||||
---------------------
|
||||
|
||||
* The short option for ``--headers`` is now ``-h`` (``-t`` has been
|
||||
removed, for usage use ``--help``)
|
||||
* Form data and URL parameters can have multiple fields with the same name
|
||||
(e.g.,``http -f url a=1 a=2``)
|
||||
* Added ``--check-status`` to exit with an error on HTTP 3xx, 4xx and
|
||||
5xx (3, 4, and 5, respectively)
|
||||
* If the output is piped to another program or redirected to a file,
|
||||
the default behaviour is to only print the response body
|
||||
(It can still be overwritten via the ``--print`` flag.)
|
||||
* Improved highlighting of HTTP headers
|
||||
* Added query string parameters (``param==value``)
|
||||
* Added support for terminal colors under Windows
|
||||
|
||||
|
||||
`0.2.5`_ (2012-07-17)
|
||||
---------------------
|
||||
|
||||
* Unicode characters in prettified JSON now don't get escaped for
|
||||
improved readability
|
||||
* --auth now prompts for a password if only a username provided
|
||||
* Added support for request payloads from a file path with automatic
|
||||
``Content-Type`` (``http URL @/path``)
|
||||
* Fixed missing query string when displaying the request headers via
|
||||
``--verbose``
|
||||
* Fixed Content-Type for requests with no data
|
||||
|
||||
|
||||
`0.2.2`_ (2012-06-24)
|
||||
---------------------
|
||||
|
||||
* The ``METHOD`` positional argument can now be omitted (defaults to
|
||||
``GET``, or to ``POST`` with data)
|
||||
* Fixed --verbose --form
|
||||
* Added support for Tox
|
||||
|
||||
|
||||
`0.2.1`_ (2012-06-13)
|
||||
---------------------
|
||||
|
||||
* Added compatibility with ``requests-0.12.1``
|
||||
* Dropped custom JSON and HTTP lexers in favor of the ones newly included
|
||||
in ``pygments-1.5``
|
||||
|
||||
|
||||
`0.2.0`_ (2012-04-25)
|
||||
---------------------
|
||||
|
||||
* Added Python 3 support
|
||||
* Added the ability to print the HTTP request as well as the response
|
||||
(see ``--print`` and ``--verbose``)
|
||||
* Added support for Digest authentication
|
||||
* Added file upload support
|
||||
(``http -f POST file_field_name@/path/to/file``)
|
||||
* Improved syntax highlighting for JSON
|
||||
* Added support for field name escaping
|
||||
* Many bug fixes
|
||||
|
||||
|
||||
`0.1.6`_ (2012-03-04)
|
||||
---------------------
|
||||
|
||||
* Fixed ``setup.py``
|
||||
|
||||
|
||||
`0.1.5`_ (2012-03-04)
|
||||
---------------------
|
||||
|
||||
* Many improvements and bug fixes
|
||||
|
||||
|
||||
`0.1.4`_ (2012-02-28)
|
||||
---------------------
|
||||
|
||||
* Many improvements and bug fixes
|
||||
|
||||
|
||||
`0.1`_ (2012-02-25)
|
||||
-------------------
|
||||
|
||||
* Initial public release
|
||||
|
||||
|
||||
.. _`0.1`: https://github.com/jkbrzt/httpie/commit/b966efa
|
||||
.. _0.1.4: https://github.com/jkbrzt/httpie/compare/b966efa...0.1.4
|
||||
.. _0.1.5: https://github.com/jkbrzt/httpie/compare/0.1.4...0.1.5
|
||||
.. _0.1.6: https://github.com/jkbrzt/httpie/compare/0.1.5...0.1.6
|
||||
.. _0.2.0: https://github.com/jkbrzt/httpie/compare/0.1.6...0.2.0
|
||||
.. _0.2.1: https://github.com/jkbrzt/httpie/compare/0.2.0...0.2.1
|
||||
.. _0.2.2: https://github.com/jkbrzt/httpie/compare/0.2.1...0.2.2
|
||||
.. _0.2.5: https://github.com/jkbrzt/httpie/compare/0.2.2...0.2.5
|
||||
.. _0.2.6: https://github.com/jkbrzt/httpie/compare/0.2.5...0.2.6
|
||||
.. _0.2.7: https://github.com/jkbrzt/httpie/compare/0.2.5...0.2.7
|
||||
.. _0.3.0: https://github.com/jkbrzt/httpie/compare/0.2.7...0.3.0
|
||||
.. _0.4.0: https://github.com/jkbrzt/httpie/compare/0.3.0...0.4.0
|
||||
.. _0.4.1: https://github.com/jkbrzt/httpie/compare/0.4.0...0.4.1
|
||||
.. _0.5.0: https://github.com/jkbrzt/httpie/compare/0.4.1...0.5.0
|
||||
.. _0.5.1: https://github.com/jkbrzt/httpie/compare/0.5.0...0.5.1
|
||||
.. _0.6.0: https://github.com/jkbrzt/httpie/compare/0.5.1...0.6.0
|
||||
.. _0.7.1: https://github.com/jkbrzt/httpie/compare/0.6.0...0.7.1
|
||||
.. _0.8.0: https://github.com/jkbrzt/httpie/compare/0.7.1...0.8.0
|
||||
.. _0.9.0: https://github.com/jkbrzt/httpie/compare/0.8.0...0.9.0
|
||||
.. _0.9.1: https://github.com/jkbrzt/httpie/compare/0.9.0...0.9.1
|
||||
.. _0.9.2: https://github.com/jkbrzt/httpie/compare/0.9.1...0.9.2
|
||||
.. _0.9.3: https://github.com/jkbrzt/httpie/compare/0.9.2...0.9.3
|
||||
.. _1.0.0-dev: https://github.com/jkbrzt/httpie/compare/0.9.3...master
|
@ -1,7 +1,7 @@
|
||||
Contributing to HTTPie
|
||||
######################
|
||||
|
||||
Bug reports and code and documentation patches are greatly appretiated. You can
|
||||
Bug reports and code and documentation patches are greatly appreciated. You can
|
||||
also help by using the development version of HTTPie and reporting any bugs you
|
||||
might encounter.
|
||||
|
||||
@ -87,9 +87,9 @@ Don't forget to add yourself to `AUTHORS.rst`_.
|
||||
|
||||
|
||||
.. _Tox: http://tox.testrun.org
|
||||
.. _supported Python environments: https://github.com/jakubroztocil/httpie/blob/master/tox.ini
|
||||
.. _existing issues: https://github.com/jakubroztocil/httpie/issues?state=open
|
||||
.. _AUTHORS.rst: https://github.com/jakubroztocil/httpie/blob/master/AUTHORS.rst
|
||||
.. _supported Python environments: https://github.com/jkbrzt/httpie/blob/master/tox.ini
|
||||
.. _existing issues: https://github.com/jkbrzt/httpie/issues?state=open
|
||||
.. _AUTHORS.rst: https://github.com/jkbrzt/httpie/blob/master/AUTHORS.rst
|
||||
.. _pytest: http://pytest.org/
|
||||
.. _Style Guide for Python Code: http://python.org/dev/peps/pep-0008/
|
||||
.. _test suite: https://github.com/jakubroztocil/httpie/tree/master/tests
|
||||
.. _test suite: https://github.com/jkbrzt/httpie/tree/master/tests
|
||||
|
2
LICENSE
2
LICENSE
@ -1,4 +1,4 @@
|
||||
Copyright © 2012 Jakub Roztocil <jakub@roztocil.name>
|
||||
Copyright © 2012-2015 Jakub Roztocil <jakub@roztocil.co>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@ -1 +1,4 @@
|
||||
include README.rst LICENSE
|
||||
include LICENSE
|
||||
include README.rst
|
||||
include CHANGELOG.rst
|
||||
include AUTHORS.rst
|
||||
|
326
README.rst
326
README.rst
@ -2,34 +2,30 @@
|
||||
HTTPie: a CLI, cURL-like tool for humans
|
||||
****************************************
|
||||
|
||||
|
||||
HTTPie (pronounced *aych-tee-tee-pie*) is a **command line HTTP client**. Its
|
||||
goal is to make CLI interaction with web services as **human-friendly** as
|
||||
possible. It provides a simple ``http`` command that allows for sending
|
||||
HTTPie (pronounced *aitch-tee-tee-pie*) is a **command line HTTP client**.
|
||||
Its goal is to make CLI interaction with web services as **human-friendly**
|
||||
as possible. It provides a simple ``http`` command that allows for sending
|
||||
arbitrary HTTP requests using a simple and natural syntax, and displays
|
||||
colorized responses. HTTPie can be used for **testing, debugging**, and
|
||||
colorized output. HTTPie can be used for **testing, debugging**, and
|
||||
generally **interacting** with HTTP servers.
|
||||
|
||||
|
||||
.. image:: https://github.com/jakubroztocil/httpie/raw/master/httpie.png
|
||||
.. image:: https://raw.githubusercontent.com/jkbrzt/httpie/master/httpie.png
|
||||
:alt: HTTPie compared to cURL
|
||||
:width: 835
|
||||
:height: 835
|
||||
:width: 679
|
||||
:height: 781
|
||||
:align: center
|
||||
|
||||
|
||||
------
|
||||
|
||||
|
||||
.. image:: https://raw.github.com/claudiatd/httpie-artwork/master/images/httpie_logo_simple.png
|
||||
:alt: HTTPie logo
|
||||
:align: center
|
||||
|
||||
HTTPie is written in Python, and under the hood it uses the excellent
|
||||
`Requests`_ and `Pygments`_ libraries.
|
||||
|
||||
|
||||
**Table of Contents**
|
||||
-----
|
||||
|
||||
|pypi| |unix_build| |windows_build| |coverage|
|
||||
|
||||
-----
|
||||
|
||||
|
||||
.. contents::
|
||||
@ -63,11 +59,6 @@ Installation
|
||||
============
|
||||
|
||||
|
||||
|
||||
------------------------
|
||||
Stable version |version|
|
||||
------------------------
|
||||
|
||||
On **Mac OS X**, HTTPie can be installed via `Homebrew <http://brew.sh/>`_:
|
||||
|
||||
.. code-block:: bash
|
||||
@ -75,9 +66,16 @@ On **Mac OS X**, HTTPie can be installed via `Homebrew <http://brew.sh/>`_:
|
||||
$ brew install httpie
|
||||
|
||||
|
||||
Most **Linux** distributions provide a package that can be installed via
|
||||
system package manager, e.g. ``yum install httpie`` or ``apt-get install httpie``.
|
||||
Note that the package might include a slightly older version of HTTPie.
|
||||
Most **Linux** distributions provide a package that can be installed using the
|
||||
system package manager, e.g.:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Debian-based distributions such as Ubuntu:
|
||||
$ apt-get install httpie
|
||||
|
||||
# RPM-based distributions:
|
||||
$ yum install httpie
|
||||
|
||||
|
||||
A **universal installation method** (that works on **Windows**, Mac OS X, Linux, …,
|
||||
@ -86,24 +84,20 @@ and provides the latest version) is to use `pip`_:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Make sure we have an up-to-date version of pip and setuptools:
|
||||
$ pip install --upgrade pip setuptools
|
||||
|
||||
$ pip install --upgrade httpie
|
||||
|
||||
|
||||
If the above fails, please use ``easy_install`` instead (``$ easy_install httpie``).
|
||||
|
||||
|
||||
(If ``pip`` installation fails for some reason, you can try
|
||||
``easy_install httpie`` as a fallback.)
|
||||
|
||||
|
||||
-------------------
|
||||
Development version
|
||||
-------------------
|
||||
|
||||
=========== ============= =============
|
||||
Tests Mac/Linux Windows
|
||||
|coverage| |unix| |windows|
|
||||
=========== ============= =============
|
||||
|
||||
|
||||
The **latest development version** can be installed directly from GitHub:
|
||||
|
||||
.. code-block:: bash
|
||||
@ -112,7 +106,7 @@ The **latest development version** can be installed directly from GitHub:
|
||||
$ brew install httpie --HEAD
|
||||
|
||||
# Universal
|
||||
$ pip install --upgrade https://github.com/jakubroztocil/httpie/tarball/master
|
||||
$ pip install --upgrade https://github.com/jkbrzt/httpie/tarball/master
|
||||
|
||||
|
||||
|
||||
@ -165,12 +159,12 @@ See the request that is being sent using one of the `output options`_:
|
||||
|
||||
|
||||
Use `Github API`_ to post a comment on an
|
||||
`issue <https://github.com/jakubroztocil/httpie/issues/83>`_
|
||||
`issue <https://github.com/jkbrzt/httpie/issues/83>`_
|
||||
with `authentication`_:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ http -a USERNAME POST https://api.github.com/repos/jakubroztocil/httpie/issues/83/comments body='HTTPie is awesome!'
|
||||
$ http -a USERNAME POST https://api.github.com/repos/jkbrzt/httpie/issues/83/comments body='HTTPie is awesome!'
|
||||
|
||||
|
||||
Upload a file using `redirected input`_:
|
||||
@ -283,7 +277,7 @@ If the port is omitted, then port 80 is assumed.
|
||||
GET / HTTP/1.1
|
||||
Host: localhost
|
||||
|
||||
If find yourself manually constructing URLs with **querystring parameters**
|
||||
If you find yourself manually constructing URLs with **querystring parameters**
|
||||
on the terminal, you may appreciate the ``param==value`` syntax for appending
|
||||
URL parameters so that you don't have to worry about escaping the ``&``
|
||||
separators. To search for ``HTTPie`` on Google Images you could use this
|
||||
@ -321,7 +315,7 @@ their type is distinguished only by the separator used:
|
||||
+-----------------------+-----------------------------------------------------+
|
||||
| URL parameters | Appends the given name/value pair as a query |
|
||||
| ``name==value`` | string parameter to the URL. |
|
||||
| | The ``==`` separator is used |
|
||||
| | The ``==`` separator is used. |
|
||||
+-----------------------+-----------------------------------------------------+
|
||||
| Data Fields | Request data fields to be serialized as a JSON |
|
||||
| ``field=value``, | object (default), or to be form-encoded |
|
||||
@ -362,7 +356,7 @@ object by default. HTTPie also automatically sets the following headers,
|
||||
both of which can be overwritten:
|
||||
|
||||
================ =======================================
|
||||
``Content-Type`` ``application/json; charset=utf-8``
|
||||
``Content-Type`` ``application/json``
|
||||
``Accept`` ``application/json``
|
||||
================ =======================================
|
||||
|
||||
@ -381,8 +375,8 @@ Simple example:
|
||||
|
||||
PUT / HTTP/1.1
|
||||
Accept: application/json
|
||||
Accept-Encoding: identity, deflate, compress, gzip
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Accept-Encoding: gzip, deflate
|
||||
Content-Type: application/json
|
||||
Host: example.org
|
||||
|
||||
{
|
||||
@ -408,7 +402,7 @@ fields using ``=@`` and ``:=@``:
|
||||
|
||||
PUT /person/1 HTTP/1.1
|
||||
Accept: application/json
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Content-Type: application/json
|
||||
Host: api.example.com
|
||||
|
||||
{
|
||||
@ -452,7 +446,8 @@ Regular Forms
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ http --form POST api.example.org/person/1 name='John Smith' email=john@example.org cv=@~/Documents/cv.txt
|
||||
$ http --form POST api.example.org/person/1 name='John Smith' \
|
||||
email=john@example.org cv=@~/Documents/cv.txt
|
||||
|
||||
|
||||
.. code-block:: http
|
||||
@ -497,14 +492,15 @@ To set custom headers you can use the ``Header:Value`` notation:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ http example.org User-Agent:Bacon/1.0 'Cookie:valued-visitor=yes;foo=bar' X-Foo:Bar Referer:http://httpie.org/
|
||||
$ http example.org User-Agent:Bacon/1.0 'Cookie:valued-visitor=yes;foo=bar' \
|
||||
X-Foo:Bar Referer:http://httpie.org/
|
||||
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
GET / HTTP/1.1
|
||||
Accept: */*
|
||||
Accept-Encoding: identity, deflate, compress, gzip
|
||||
Accept-Encoding: gzip, deflate
|
||||
Cookie: valued-visitor=yes;foo=bar
|
||||
Host: example.org
|
||||
Referer: http://httpie.org/
|
||||
@ -518,7 +514,7 @@ There are a couple of default headers that HTTPie sets:
|
||||
|
||||
GET / HTTP/1.1
|
||||
Accept: */*
|
||||
Accept-Encoding: identity, deflate, compress, gzip
|
||||
Accept-Encoding: gzip, deflate
|
||||
User-Agent: HTTPie/<version>
|
||||
Host: <taken-from-URL>
|
||||
|
||||
@ -538,7 +534,7 @@ The currently supported authentication schemes are Basic and Digest
|
||||
the argument. Or, if you only specify a username
|
||||
(``-a username``), you'll be prompted for
|
||||
the password before the request is sent.
|
||||
To send a an empty password, pass ``username:``.
|
||||
To send an empty password, pass ``username:``.
|
||||
The ``username:password@hostname`` URL syntax is
|
||||
supported as well (but credentials passed via ``-a``
|
||||
have higher priority).
|
||||
@ -591,11 +587,13 @@ Authorization information from your ``~/.netrc`` file is honored as well:
|
||||
Auth Plugins
|
||||
------------
|
||||
|
||||
* `httpie-oauth <https://github.com/jakubroztocil/httpie-oauth>`_: OAuth
|
||||
* `httpie-ntlm <https://github.com/jakubroztocil/httpie-ntlm>`_: NTLM (NT LAN Manager)
|
||||
* `httpie-oauth <https://github.com/jkbrzt/httpie-oauth>`_: OAuth
|
||||
* `httpie-ntlm <https://github.com/jkbrzt/httpie-ntlm>`_: NTLM (NT LAN Manager)
|
||||
* `httpie-negotiate <https://github.com/ndzou/httpie-negotiate>`_: SPNEGO (GSS Negotiate)
|
||||
* `requests-hawk <https://github.com/mozilla-services/requests-hawk>`_: Hawk
|
||||
* `httpie-api-auth <https://github.com/pd/httpie-api-auth>`_: ApiAuth
|
||||
* `httpie-edgegrid <https://github.com/akamai-open/httpie-edgegrid>`_: EdgeGrid
|
||||
* `httpie-jwt-auth <https://github.com/teracyhq/httpie-jwt-auth>`_: JWTAuth (JSON Web Tokens)
|
||||
|
||||
|
||||
=======
|
||||
@ -726,8 +724,8 @@ documentation examples:
|
||||
$ http --verbose PUT httpbin.org/put hello=world
|
||||
PUT /put HTTP/1.1
|
||||
Accept: application/json
|
||||
Accept-Encoding: identity, deflate, compress, gzip
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Accept-Encoding: gzip, deflate
|
||||
Content-Type: application/json
|
||||
Host: httpbin.org
|
||||
User-Agent: HTTPie/0.2.7dev
|
||||
|
||||
@ -827,7 +825,7 @@ You can even pipe web services together using HTTPie:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ http GET https://api.github.com/repos/jakubroztocil/httpie | http POST httpbin.org/post
|
||||
$ http GET https://api.github.com/repos/jkbrzt/httpie | http POST httpbin.org/post
|
||||
|
||||
|
||||
You can use ``cat`` to enter multiline data on the terminal:
|
||||
@ -897,7 +895,7 @@ Colors and Formatting
|
||||
---------------------
|
||||
|
||||
Syntax highlighting is applied to HTTP headers and bodies (where it makes
|
||||
sense). You can choose your prefered color scheme via the ``--style`` option
|
||||
sense). You can choose your preferred color scheme via the ``--style`` option
|
||||
if you don't like the default one (see ``$ http --help`` for the possible
|
||||
values).
|
||||
|
||||
@ -1011,19 +1009,19 @@ is being saved to a file.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ http --download https://github.com/jakubroztocil/httpie/tarball/master
|
||||
$ http --download https://github.com/jkbrzt/httpie/tarball/master
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Connection: keep-alive
|
||||
Content-Disposition: attachment; filename=jakubroztocil-httpie-0.4.1-33-gfc4f70a.tar.gz
|
||||
Content-Disposition: attachment; filename=jkbrzt-httpie-0.4.1-33-gfc4f70a.tar.gz
|
||||
Content-Length: 505530
|
||||
Content-Type: application/x-gzip
|
||||
Server: GitHub.com
|
||||
Vary: Accept-Encoding
|
||||
|
||||
Downloading 494.89 kB to "jakubroztocil-httpie-0.4.1-33-gfc4f70a.tar.gz"
|
||||
Downloading 494.89 kB to "jkbrzt-httpie-0.4.1-33-gfc4f70a.tar.gz"
|
||||
/ 21.01% 104.00 kB 47.55 kB/s 0:00:08 ETA
|
||||
|
||||
|
||||
@ -1037,7 +1035,7 @@ headers and progress are still shown in the terminal:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ http -d https://github.com/jakubroztocil/httpie/tarball/master | tar zxf -
|
||||
$ http -d https://github.com/jkbrzt/httpie/tarball/master | tar zxf -
|
||||
|
||||
|
||||
If ``--output, -o`` is specified, you can resume a partial download using the
|
||||
@ -1277,14 +1275,17 @@ and usage from scripts, where HTTPie serves as a generic HTTP client.
|
||||
As HTTPie is still under heavy development, the existing command line
|
||||
syntax and some of the ``--OPTIONS`` may change slightly before
|
||||
HTTPie reaches its final version ``1.0``. All changes are recorded in the
|
||||
`changelog`_.
|
||||
`change log`_.
|
||||
|
||||
|
||||
==========
|
||||
Contribute
|
||||
==========
|
||||
|
||||
Please see `CONTRIBUTING`_.
|
||||
=======
|
||||
Authors
|
||||
=======
|
||||
|
||||
|
||||
`Jakub Roztocil`_ (`@jkbrzt`_) created HTTPie and `these fine people`_
|
||||
have contributed.
|
||||
|
||||
|
||||
====
|
||||
@ -1293,194 +1294,51 @@ Logo
|
||||
|
||||
Please see `claudiatd/httpie-artwork`_
|
||||
|
||||
=======
|
||||
Authors
|
||||
=======
|
||||
|
||||
`Jakub Roztocil`_ (`@jakubroztocil`_) created HTTPie and `these fine people`_
|
||||
have contributed.
|
||||
==========
|
||||
Contribute
|
||||
==========
|
||||
|
||||
Please see `CONTRIBUTING <https://github.com/jkbrzt/httpie/blob/master/CONTRIBUTING.rst>`_.
|
||||
|
||||
|
||||
==========
|
||||
Change Log
|
||||
==========
|
||||
|
||||
Please see `CHANGELOG <https://github.com/jkbrzt/httpie/blob/master/CHANGELOG.rst>`_.
|
||||
|
||||
|
||||
=======
|
||||
Licence
|
||||
=======
|
||||
|
||||
Please see `LICENSE`_.
|
||||
Please see `LICENSE <https://github.com/jkbrzt/httpie/blob/master/LICENSE>`_.
|
||||
|
||||
|
||||
=========
|
||||
Changelog
|
||||
=========
|
||||
|
||||
*You can click a version name to see a diff with the previous one.*
|
||||
|
||||
* `1.0.0-dev`_
|
||||
* `0.9.1`_ (2015-02-07)
|
||||
* Added support for Requests transport adapter plugins
|
||||
to enable plugin-provided features such as
|
||||
`unix socket <https://github.com/msabramo/httpie-unixsocket>`_
|
||||
communication and
|
||||
`HTTP/2 <https://github.com/jakubroztocil/httpie-http2>`_.
|
||||
* `0.9.0`_ (2015-01-31)
|
||||
* Added ``--cert`` and ``--cert-key`` parameters to specify a client side
|
||||
certificate and private key for SSL
|
||||
* Improved unicode support.
|
||||
* Improved terminal color depth detection via ``curses``.
|
||||
* 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
|
||||
separators by HTTPie).
|
||||
* Switched from ``unittest`` to ``pytest``.
|
||||
* Added Python `wheel` support.
|
||||
* Various test suite improvements.
|
||||
* Added `CONTRIBUTING`_.
|
||||
* Fixed ``User-Agent`` overwriting when used within a session.
|
||||
* Fixed handling of empty passwords in URL credentials.
|
||||
* Fixed multiple file uploads with the same form field name.
|
||||
* Fixed ``--output=/dev/null`` on Linux.
|
||||
* Miscellaneous bugfixes.
|
||||
* `0.8.0`_ (2014-01-25)
|
||||
* Added ``field=@file.txt`` and ``field:=@file.json`` for embedding
|
||||
the contents of text and JSON files into request data.
|
||||
* Added curl-style shorthand for localhost.
|
||||
* Fixed request ``Host`` header value output so that it doesn't contain
|
||||
credentials, if included in the URL.
|
||||
* `0.7.1`_ (2013-09-24)
|
||||
* Added ``--ignore-stdin``.
|
||||
* Added support for auth plugins.
|
||||
* Improved ``--help`` output.
|
||||
* Improved ``Content-Disposition`` parsing for ``--download`` mode.
|
||||
* Update to Requests 2.0.0
|
||||
* `0.6.0`_ (2013-06-03)
|
||||
* XML data is now formatted.
|
||||
* ``--session`` and ``--session-read-only`` now also accept paths to
|
||||
session files (eg. ``http --session=/tmp/session.json example.org``).
|
||||
* `0.5.1`_ (2013-05-13)
|
||||
* ``Content-*`` and ``If-*`` request headers are not stored in sessions
|
||||
anymore as they are request-specific.
|
||||
* `0.5.0`_ (2013-04-27)
|
||||
* Added a `download mode`_ via ``--download``.
|
||||
* Bugfixes.
|
||||
* `0.4.1`_ (2013-02-26)
|
||||
* Fixed ``setup.py``.
|
||||
* `0.4.0`_ (2013-02-22)
|
||||
* Python 3.3 compatibility.
|
||||
* Requests >= v1.0.4 compatibility.
|
||||
* Added support for credentials in URL.
|
||||
* Added ``--no-option`` for every ``--option`` to be config-friendly.
|
||||
* Mutually exclusive arguments can be specified multiple times. The
|
||||
last value is used.
|
||||
* `0.3.0`_ (2012-09-21)
|
||||
* Allow output redirection on Windows.
|
||||
* Added configuration file.
|
||||
* Added persistent session support.
|
||||
* Renamed ``--allow-redirects`` to ``--follow``.
|
||||
* Improved the usability of ``http --help``.
|
||||
* Fixed installation on Windows with Python 3.
|
||||
* Fixed colorized output on Windows with Python 3.
|
||||
* CRLF HTTP header field separation in the output.
|
||||
* Added exit status code ``2`` for timed-out requests.
|
||||
* Added the option to separate colorizing and formatting
|
||||
(``--pretty=all``, ``--pretty=colors`` and ``--pretty=format``).
|
||||
``--ugly`` has bee removed in favor of ``--pretty=none``.
|
||||
* `0.2.7`_ (2012-08-07)
|
||||
* Compatibility with Requests 0.13.6.
|
||||
* Streamed terminal output. ``--stream, -S`` can be used to enable
|
||||
streaming also with ``--pretty`` and to ensure a more frequent output
|
||||
flushing.
|
||||
* Support for efficient large file downloads.
|
||||
* Sort headers by name (unless ``--pretty=none``).
|
||||
* Response body is fetched only when needed (e.g., not with ``--headers``).
|
||||
* Improved content type matching.
|
||||
* Updated Solarized color scheme.
|
||||
* Windows: Added ``--output FILE`` to store output into a file
|
||||
(piping results in corrupted data on Windows).
|
||||
* Proper handling of binary requests and responses.
|
||||
* Fixed printing of ``multipart/form-data`` requests.
|
||||
* Renamed ``--traceback`` to ``--debug``.
|
||||
* `0.2.6`_ (2012-07-26)
|
||||
* The short option for ``--headers`` is now ``-h`` (``-t`` has been
|
||||
removed, for usage use ``--help``).
|
||||
* Form data and URL parameters can have multiple fields with the same name
|
||||
(e.g.,``http -f url a=1 a=2``).
|
||||
* Added ``--check-status`` to exit with an error on HTTP 3xx, 4xx and
|
||||
5xx (3, 4, and 5, respectively).
|
||||
* If the output is piped to another program or redirected to a file,
|
||||
the default behaviour is to only print the response body.
|
||||
(It can still be overwritten via the ``--print`` flag.)
|
||||
* Improved highlighting of HTTP headers.
|
||||
* Added query string parameters (``param==value``).
|
||||
* Added support for terminal colors under Windows.
|
||||
* `0.2.5`_ (2012-07-17)
|
||||
* Unicode characters in prettified JSON now don't get escaped for
|
||||
improved readability.
|
||||
* --auth now prompts for a password if only a username provided.
|
||||
* Added support for request payloads from a file path with automatic
|
||||
``Content-Type`` (``http URL @/path``).
|
||||
* Fixed missing query string when displaying the request headers via
|
||||
``--verbose``.
|
||||
* Fixed Content-Type for requests with no data.
|
||||
* `0.2.2`_ (2012-06-24)
|
||||
* The ``METHOD`` positional argument can now be omitted (defaults to
|
||||
``GET``, or to ``POST`` with data).
|
||||
* Fixed --verbose --form.
|
||||
* Added support for `Tox`_.
|
||||
* `0.2.1`_ (2012-06-13)
|
||||
* Added compatibility with ``requests-0.12.1``.
|
||||
* Dropped custom JSON and HTTP lexers in favor of the ones newly included
|
||||
in ``pygments-1.5``.
|
||||
* `0.2.0`_ (2012-04-25)
|
||||
* Added Python 3 support.
|
||||
* Added the ability to print the HTTP request as well as the response
|
||||
(see ``--print`` and ``--verbose``).
|
||||
* Added support for Digest authentication.
|
||||
* Added file upload support
|
||||
(``http -f POST file_field_name@/path/to/file``).
|
||||
* Improved syntax highlighting for JSON.
|
||||
* Added support for field name escaping.
|
||||
* Many bug fixes.
|
||||
* `0.1.6`_ (2012-03-04)
|
||||
|
||||
|
||||
.. _Requests: http://python-requests.org
|
||||
.. _Pygments: http://pygments.org/
|
||||
.. _pip: http://www.pip-installer.org/en/latest/index.html
|
||||
.. _Github API: http://developer.github.com/v3/issues/comments/#create-a-comment
|
||||
.. _these fine people: https://github.com/jakubroztocil/httpie/contributors
|
||||
.. _Jakub Roztocil: http://subtleapps.com
|
||||
.. _@jakubroztocil: https://twitter.com/jakubroztocil
|
||||
.. _these fine people: https://github.com/jkbrzt/httpie/contributors
|
||||
.. _Jakub Roztocil: http://roztocil.co
|
||||
.. _@jkbrzt: https://twitter.com/jkbrzt
|
||||
.. _claudiatd/httpie-artwork: https://github.com/claudiatd/httpie-artwork
|
||||
.. _0.1.6: https://github.com/jakubroztocil/httpie/compare/0.1.4...0.1.6
|
||||
.. _0.2.0: https://github.com/jakubroztocil/httpie/compare/0.1.6...0.2.0
|
||||
.. _0.2.1: https://github.com/jakubroztocil/httpie/compare/0.2.0...0.2.1
|
||||
.. _0.2.2: https://github.com/jakubroztocil/httpie/compare/0.2.1...0.2.2
|
||||
.. _0.2.5: https://github.com/jakubroztocil/httpie/compare/0.2.2...0.2.5
|
||||
.. _0.2.6: https://github.com/jakubroztocil/httpie/compare/0.2.5...0.2.6
|
||||
.. _0.2.7: https://github.com/jakubroztocil/httpie/compare/0.2.5...0.2.7
|
||||
.. _0.3.0: https://github.com/jakubroztocil/httpie/compare/0.2.7...0.3.0
|
||||
.. _0.4.0: https://github.com/jakubroztocil/httpie/compare/0.3.0...0.4.0
|
||||
.. _0.4.1: https://github.com/jakubroztocil/httpie/compare/0.4.0...0.4.1
|
||||
.. _0.5.0: https://github.com/jakubroztocil/httpie/compare/0.4.1...0.5.0
|
||||
.. _0.5.1: https://github.com/jakubroztocil/httpie/compare/0.5.0...0.5.1
|
||||
.. _0.6.0: https://github.com/jakubroztocil/httpie/compare/0.5.1...0.6.0
|
||||
.. _0.7.1: https://github.com/jakubroztocil/httpie/compare/0.6.0...0.7.1
|
||||
.. _0.8.0: https://github.com/jakubroztocil/httpie/compare/0.7.1...0.8.0
|
||||
.. _0.9.0: https://github.com/jakubroztocil/httpie/compare/0.8.0...0.9.0
|
||||
.. _0.9.1: https://github.com/jakubroztocil/httpie/compare/0.9.0...0.9.1
|
||||
.. _1.0.0-dev: https://github.com/jakubroztocil/httpie/compare/0.9.0...master
|
||||
.. _LICENSE: https://github.com/jakubroztocil/httpie/blob/master/LICENSE
|
||||
.. _Tox: http://tox.testrun.org
|
||||
.. _CONTRIBUTING: https://github.com/jakubroztocil/httpie/blob/master/CONTRIBUTING.rst
|
||||
|
||||
|
||||
.. |version| image:: https://badge.fury.io/py/httpie.svg
|
||||
:target: http://badge.fury.io/py/httpie
|
||||
.. |pypi| image:: https://img.shields.io/pypi/v/httpie.svg?style=flat-square&label=latest%20version
|
||||
:target: https://pypi.python.org/pypi/httpie
|
||||
:alt: Latest version released on PyPi
|
||||
|
||||
.. |coverage| image:: https://coveralls.io/repos/jakubroztocil/httpie/badge.svg?branch=master
|
||||
:target: https://coveralls.io/r/jakubroztocil/httpie?branch=master
|
||||
.. |coverage| image:: https://img.shields.io/coveralls/jkbrzt/httpie/master.svg?style=flat-square
|
||||
:target: https://coveralls.io/r/jkbrzt/httpie?branch=master
|
||||
:alt: Test coverage
|
||||
|
||||
.. |unix| image:: https://api.travis-ci.org/jakubroztocil/httpie.svg
|
||||
:target: http://travis-ci.org/jakubroztocil/httpie
|
||||
:alt: Build Status of the master branch on Mac/Linux
|
||||
.. |unix_build| image:: https://img.shields.io/travis/jkbrzt/httpie/master.svg?style=flat-square&label=unix%20build
|
||||
:target: http://travis-ci.org/jkbrzt/httpie
|
||||
:alt: Build status of the master branch on Mac/Linux
|
||||
|
||||
.. |windows| image:: https://ci.appveyor.com/api/projects/status/f7b5dogxuseq8srw
|
||||
:target: https://ci.appveyor.com/project/jakubroztocil/httpie
|
||||
:alt: Build Status of the master branch on Windows
|
||||
.. |windows_build| image:: https://img.shields.io/appveyor/ci/jkbrzt/httpie.svg?style=flat-square&label=windows%20build
|
||||
:target: https://ci.appveyor.com/project/jkbrzt/httpie
|
||||
:alt: Build status of the master branch on Windows
|
||||
|
@ -1,4 +1,4 @@
|
||||
# https://ci.appveyor.com/project/jakubroztocil/httpie
|
||||
# https://ci.appveyor.com/project/jkbrzt/httpie
|
||||
build: false
|
||||
environment:
|
||||
matrix:
|
||||
@ -8,8 +8,9 @@ init:
|
||||
- "ECHO %PYTHON%"
|
||||
- ps: "ls C:/Python*"
|
||||
install:
|
||||
- ps: (new-object net.webclient).DownloadFile('https://raw.github.com/pypa/pip/master/contrib/get-pip.py', 'C:/get-pip.py')
|
||||
- "%PYTHON%/python.exe C:/get-pip.py"
|
||||
# - ps: (new-object net.webclient).DownloadFile('https://bootstrap.pypa.io/get-pip.py', 'C:/get-pip.py')
|
||||
# - "%PYTHON%/python.exe C:/get-pip.py"
|
||||
- "%PYTHON%/Scripts/pip.exe install -U pip setuptools"
|
||||
- "%PYTHON%/Scripts/pip.exe install -e ."
|
||||
test_script:
|
||||
- "%PYTHON%/Scripts/pip.exe --version"
|
||||
|
23
httpie-completion.bash
Normal file
23
httpie-completion.bash
Normal file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
_http_complete() {
|
||||
local cur_word=${COMP_WORDS[COMP_CWORD]}
|
||||
local prev_word=${COMP_WORDS[COMP_CWORD - 1]}
|
||||
|
||||
if [[ "$cur_word" == -* ]]; then
|
||||
_http_complete_options "$cur_word"
|
||||
fi
|
||||
}
|
||||
|
||||
complete -o default -F _http_complete http
|
||||
|
||||
_http_complete_options() {
|
||||
local cur_word=$1
|
||||
local options="-j --json -f --form --pretty -s --style -p --print
|
||||
-v --verbose -h --headers -b --body -S --stream -o --output -d --download
|
||||
-c --continue --session --session-read-only -a --auth --auth-type --proxy
|
||||
--follow --verify --cert --cert-key --timeout --check-status --ignore-stdin
|
||||
--help --version --traceback --debug"
|
||||
COMPREPLY=( $( compgen -W "$options" -- "$cur_word" ) )
|
||||
}
|
BIN
httpie.png
BIN
httpie.png
Binary file not shown.
Before Width: | Height: | Size: 446 KiB After Width: | Height: | Size: 182 KiB |
@ -3,7 +3,7 @@ HTTPie - a CLI, cURL-like tool for humans.
|
||||
|
||||
"""
|
||||
__author__ = 'Jakub Roztocil'
|
||||
__version__ = '0.9.1'
|
||||
__version__ = '0.9.3'
|
||||
__licence__ = 'BSD'
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@ NOTE: the CLI interface may change before reaching v1.0.
|
||||
|
||||
"""
|
||||
from textwrap import dedent, wrap
|
||||
#noinspection PyCompatibility
|
||||
# noinspection PyCompatibility
|
||||
from argparse import (RawDescriptionHelpFormatter, FileType,
|
||||
OPTIONAL, ZERO_OR_MORE, SUPPRESS)
|
||||
|
||||
@ -49,7 +49,7 @@ parser = Parser(
|
||||
|
||||
Suggestions and bug reports are greatly appreciated:
|
||||
|
||||
https://github.com/jakubroztocil/httpie/issues
|
||||
https://github.com/jkbrzt/httpie/issues
|
||||
|
||||
""")
|
||||
)
|
||||
|
@ -3,6 +3,7 @@ import sys
|
||||
from pprint import pformat
|
||||
|
||||
import requests
|
||||
from requests.packages import urllib3
|
||||
|
||||
from httpie import sessions
|
||||
from httpie import __version__
|
||||
@ -10,14 +11,25 @@ from httpie.compat import str
|
||||
from httpie.plugins import plugin_manager
|
||||
|
||||
|
||||
try:
|
||||
# https://urllib3.readthedocs.org/en/latest/security.html
|
||||
urllib3.disable_warnings()
|
||||
except AttributeError:
|
||||
# In some rare cases, the user may have an old version of the requests
|
||||
# or urllib3, and there is no method called "disable_warnings." In these
|
||||
# cases, we don't need to call the method.
|
||||
# They may get some noisy output but execution shouldn't die. Move on.
|
||||
pass
|
||||
|
||||
|
||||
FORM = 'application/x-www-form-urlencoded; charset=utf-8'
|
||||
JSON = 'application/json; charset=utf-8'
|
||||
JSON = 'application/json'
|
||||
DEFAULT_UA = 'HTTPie/%s' % __version__
|
||||
|
||||
|
||||
def get_requests_session():
|
||||
requests_session = requests.Session()
|
||||
for cls in plugin_manager.get_trasnsport_plugins():
|
||||
for cls in plugin_manager.get_transport_plugins():
|
||||
transport_plugin = cls()
|
||||
requests_session.mount(prefix=transport_plugin.prefix,
|
||||
adapter=transport_plugin.get_adapter())
|
||||
@ -47,13 +59,13 @@ def get_response(args, config_dir):
|
||||
|
||||
|
||||
def dump_request(kwargs):
|
||||
sys.stderr.write('\n>>> requests.request(%s)\n\n'
|
||||
sys.stderr.write('\n>>> requests.request(**%s)\n\n'
|
||||
% pformat(kwargs))
|
||||
|
||||
|
||||
def encode_headers(headers):
|
||||
# This allows for unicode headers which is non-standard but practical.
|
||||
# See: https://github.com/jakubroztocil/httpie/issues/212
|
||||
# See: https://github.com/jkbrzt/httpie/issues/212
|
||||
return dict(
|
||||
(name, value.encode('utf8') if isinstance(value, str) else value)
|
||||
for name, value in headers.items()
|
||||
@ -87,7 +99,7 @@ def get_requests_kwargs(args, base_headers=None):
|
||||
# Serialize JSON data, if needed.
|
||||
data = args.data
|
||||
auto_json = data and not args.form
|
||||
if args.json or auto_json and isinstance(data, dict):
|
||||
if (args.json or auto_json) and isinstance(data, dict):
|
||||
if data:
|
||||
data = json.dumps(data)
|
||||
else:
|
||||
|
@ -2,27 +2,42 @@
|
||||
Python 2.6, 2.7, and 3.x compatibility.
|
||||
|
||||
"""
|
||||
# Borrow these from requests:
|
||||
# noinspection PyUnresolvedReferences
|
||||
from requests.compat import is_windows, bytes, str, is_py3, is_py26
|
||||
import sys
|
||||
|
||||
try:
|
||||
|
||||
is_py2 = sys.version_info[0] == 2
|
||||
is_py26 = sys.version_info[:2] == (2, 6)
|
||||
is_py27 = sys.version_info[:2] == (2, 7)
|
||||
is_py3 = sys.version_info[0] == 3
|
||||
is_pypy = 'pypy' in sys.version.lower()
|
||||
is_windows = 'win32' in str(sys.platform).lower()
|
||||
|
||||
|
||||
if is_py2:
|
||||
bytes = str
|
||||
str = unicode
|
||||
elif is_py3:
|
||||
str = str
|
||||
bytes = bytes
|
||||
|
||||
|
||||
try: # pragma: no cover
|
||||
# noinspection PyUnresolvedReferences,PyCompatibility
|
||||
from urllib.parse import urlsplit
|
||||
except ImportError:
|
||||
except ImportError: # pragma: no cover
|
||||
# noinspection PyUnresolvedReferences,PyCompatibility
|
||||
from urlparse import urlsplit
|
||||
|
||||
try:
|
||||
try: # pragma: no cover
|
||||
# noinspection PyCompatibility
|
||||
from urllib.request import urlopen
|
||||
except ImportError:
|
||||
except ImportError: # pragma: no cover
|
||||
# noinspection PyCompatibility
|
||||
from urllib2 import urlopen
|
||||
|
||||
try:
|
||||
try: # pragma: no cover
|
||||
from collections import OrderedDict
|
||||
except ImportError:
|
||||
except ImportError: # pragma: no cover
|
||||
# Python 2.6 OrderedDict class, needed for headers, parameters, etc .###
|
||||
# <https://pypi.python.org/pypi/ordereddict/1.1>
|
||||
# noinspection PyCompatibility
|
||||
|
@ -80,7 +80,7 @@ class BaseConfigDict(dict):
|
||||
class Config(BaseConfigDict):
|
||||
|
||||
name = 'config'
|
||||
helpurl = 'https://github.com/jakubroztocil/httpie#config'
|
||||
helpurl = 'https://github.com/jkbrzt/httpie#config'
|
||||
about = 'HTTPie configuration file'
|
||||
|
||||
DEFAULTS = {
|
||||
|
@ -1,7 +1,6 @@
|
||||
import sys
|
||||
|
||||
from requests.compat import is_windows
|
||||
|
||||
from httpie.compat import is_windows
|
||||
from httpie.config import DEFAULT_CONFIG_DIR, Config
|
||||
|
||||
|
||||
|
@ -67,7 +67,7 @@ def decode_args(args, stdin_encoding):
|
||||
]
|
||||
|
||||
|
||||
def main(args=sys.argv[1:], env=Environment()):
|
||||
def main(args=sys.argv[1:], env=Environment(), error=None):
|
||||
"""Run the main program and write the output to ``env.stdout``.
|
||||
|
||||
Return exit status code.
|
||||
@ -81,11 +81,14 @@ def main(args=sys.argv[1:], env=Environment()):
|
||||
if env.config.default_options:
|
||||
args = env.config.default_options + args
|
||||
|
||||
def error(msg, *args, **kwargs):
|
||||
def _error(msg, *args, **kwargs):
|
||||
msg = msg % args
|
||||
level = kwargs.get('level', 'error')
|
||||
env.stderr.write('\nhttp: %s: %s\n' % (level, msg))
|
||||
|
||||
if error is None:
|
||||
error = _error
|
||||
|
||||
debug = '--debug' in args
|
||||
traceback = debug or '--traceback' in args
|
||||
exit_status = ExitStatus.OK
|
||||
@ -183,7 +186,13 @@ def main(args=sys.argv[1:], env=Environment()):
|
||||
# Network errors vs. bugs, etc.
|
||||
if traceback:
|
||||
raise
|
||||
error('%s: %s', type(e).__name__, str(e))
|
||||
msg = str(e)
|
||||
if hasattr(e, 'request'):
|
||||
request = e.request
|
||||
if hasattr(request, 'url'):
|
||||
msg += ' while doing %s request to URL: %s' % (
|
||||
request.method, request.url)
|
||||
error('%s: %s', type(e).__name__, msg)
|
||||
exit_status = ExitStatus.ERROR
|
||||
|
||||
finally:
|
||||
|
@ -104,7 +104,7 @@ def filename_from_content_disposition(content_disposition):
|
||||
:return: the filename if present and valid, otherwise `None`
|
||||
|
||||
"""
|
||||
# attachment; filename=jakubroztocil-httpie-0.4.1-20-g40bd8f6.tar.gz
|
||||
# attachment; filename=jkbrzt-httpie-0.4.1-20-g40bd8f6.tar.gz
|
||||
|
||||
msg = Message('Content-Disposition: %s' % content_disposition)
|
||||
filename = msg.get_filename()
|
||||
|
@ -8,15 +8,15 @@ import errno
|
||||
import mimetypes
|
||||
import getpass
|
||||
from io import BytesIO
|
||||
from collections import namedtuple
|
||||
from collections import namedtuple, Iterable
|
||||
# noinspection PyCompatibility
|
||||
from argparse import ArgumentParser, ArgumentTypeError, ArgumentError
|
||||
|
||||
# TODO: Use MultiDict for headers once added to `requests`.
|
||||
# https://github.com/jakubroztocil/httpie/issues/130
|
||||
# https://github.com/jkbrzt/httpie/issues/130
|
||||
from requests.structures import CaseInsensitiveDict
|
||||
|
||||
from httpie.compat import OrderedDict, urlsplit, str
|
||||
from httpie.compat import OrderedDict, urlsplit, str, is_pypy, is_py27
|
||||
from httpie.sessions import VALID_SESSION_NAME_PATTERN
|
||||
from httpie.utils import load_json_preserve_order
|
||||
|
||||
@ -303,8 +303,8 @@ class Parser(ArgumentParser):
|
||||
# Infer the method
|
||||
has_data = (
|
||||
(not self.args.ignore_stdin and not self.env.stdin_isatty)
|
||||
or any(item.sep in SEP_GROUP_DATA_ITEMS
|
||||
for item in self.args.items)
|
||||
or any(item.sep in SEP_GROUP_DATA_ITEMS
|
||||
for item in self.args.items)
|
||||
)
|
||||
self.args.method = HTTP_POST if has_data else HTTP_GET
|
||||
|
||||
@ -378,7 +378,8 @@ class Parser(ArgumentParser):
|
||||
if self.args.prettify == PRETTY_STDOUT_TTY_ONLY:
|
||||
self.args.prettify = PRETTY_MAP[
|
||||
'all' if self.env.stdout_isatty else 'none']
|
||||
elif self.args.prettify and self.env.is_windows:
|
||||
elif (self.args.prettify and self.env.is_windows and
|
||||
self.args.output_file):
|
||||
self.error('Only terminal output can be colorized on Windows.')
|
||||
else:
|
||||
# noinspection PyTypeChecker
|
||||
@ -521,7 +522,7 @@ class AuthCredentials(KeyValue):
|
||||
|
||||
def _getpass(self, prompt):
|
||||
# To allow mocking.
|
||||
return getpass.getpass(prompt)
|
||||
return getpass.getpass(str(prompt))
|
||||
|
||||
def has_password(self):
|
||||
return self.value is not None
|
||||
@ -561,7 +562,18 @@ class AuthCredentialsArgType(KeyValueArgType):
|
||||
class RequestItemsDict(OrderedDict):
|
||||
"""Multi-value dict for URL parameters and form data."""
|
||||
|
||||
#noinspection PyMethodOverriding
|
||||
if is_pypy and is_py27:
|
||||
# Manually set keys when initialized with an iterable as PyPy
|
||||
# doesn't call __setitem__ in such case (pypy3 does).
|
||||
def __init__(self, *args, **kwargs):
|
||||
if len(args) == 1 and isinstance(args[0], Iterable):
|
||||
super(RequestItemsDict, self).__init__(**kwargs)
|
||||
for k, v in args[0]:
|
||||
self[k] = v
|
||||
else:
|
||||
super(RequestItemsDict, self).__init__(*args, **kwargs)
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def __setitem__(self, key, value):
|
||||
""" If `key` is assigned more than once, `self[key]` holds a
|
||||
`list` of all the values.
|
||||
|
@ -7,7 +7,6 @@ from pygments.formatters.terminal import TerminalFormatter
|
||||
from pygments.formatters.terminal256 import Terminal256Formatter
|
||||
from pygments.util import ClassNotFound
|
||||
|
||||
from httpie.compat import is_windows
|
||||
from httpie.plugins import FormatterPlugin
|
||||
|
||||
|
||||
@ -15,7 +14,7 @@ from httpie.plugins import FormatterPlugin
|
||||
# great and fruity seems to give the best result there.
|
||||
AVAILABLE_STYLES = set(pygments.styles.STYLE_MAP.keys())
|
||||
AVAILABLE_STYLES.add('solarized')
|
||||
DEFAULT_STYLE = 'solarized' if not is_windows else 'fruity'
|
||||
DEFAULT_STYLE = 'monokai'
|
||||
|
||||
|
||||
class ColorFormatter(FormatterPlugin):
|
||||
@ -144,6 +143,8 @@ class HTTPLexer(pygments.lexer.RegexLexer):
|
||||
}
|
||||
|
||||
|
||||
# TODO: As Solarized is not the default theme any longer, it should be removed
|
||||
# or bundled directly with Pygments so that we don't need to support it.
|
||||
class Solarized256Style(pygments.style.Style):
|
||||
"""
|
||||
solarized256
|
||||
|
@ -15,7 +15,7 @@ class AuthPlugin(BasePlugin):
|
||||
"""
|
||||
Base auth plugin class.
|
||||
|
||||
See <https://github.com/jakubroztocil/httpie-ntlm> for an example auth plugin.
|
||||
See <https://github.com/jkbrzt/httpie-ntlm> for an example auth plugin.
|
||||
|
||||
"""
|
||||
# The value that should be passed to --auth-type
|
||||
|
@ -16,7 +16,7 @@ class HTTPBasicAuth(requests.auth.HTTPBasicAuth):
|
||||
"""
|
||||
Override username/password serialization to allow unicode.
|
||||
|
||||
See https://github.com/jakubroztocil/httpie/issues/212
|
||||
See https://github.com/jkbrzt/httpie/issues/212
|
||||
|
||||
"""
|
||||
r.headers['Authorization'] = type(self).make_header(
|
||||
|
@ -60,6 +60,6 @@ class PluginManager(object):
|
||||
if issubclass(plugin, ConverterPlugin)]
|
||||
|
||||
# Adapters
|
||||
def get_trasnsport_plugins(self):
|
||||
def get_transport_plugins(self):
|
||||
return [plugin for plugin in self
|
||||
if issubclass(plugin, TransportPlugin)]
|
||||
|
@ -75,7 +75,7 @@ def get_response(requests_session, session_name,
|
||||
|
||||
|
||||
class Session(BaseConfigDict):
|
||||
helpurl = 'https://github.com/jakubroztocil/httpie#sessions'
|
||||
helpurl = 'https://github.com/jkbrzt/httpie#sessions'
|
||||
about = 'HTTPie session file'
|
||||
|
||||
def __init__(self, path, *args, **kwargs):
|
||||
|
@ -54,4 +54,3 @@ def humanize_bytes(n, precision=2):
|
||||
|
||||
# noinspection PyUnboundLocalVariable
|
||||
return '%.*f %s' % (precision, n / factor, suffix)
|
||||
|
||||
|
3
pytest.ini
Normal file
3
pytest.ini
Normal file
@ -0,0 +1,3 @@
|
||||
[pytest]
|
||||
addopts = --tb=native
|
||||
norecursedirs = tests/fixtures
|
@ -1,6 +1,7 @@
|
||||
tox
|
||||
mock
|
||||
pytest
|
||||
pytest-cov
|
||||
pytest-httpbin
|
||||
pytest-httpbin>=0.0.6
|
||||
docutils
|
||||
wheel
|
||||
|
12
setup.py
12
setup.py
@ -14,7 +14,6 @@ class PyTest(TestCommand):
|
||||
# and runs the tests with no fancy stuff like parallel execution.
|
||||
def finalize_options(self):
|
||||
TestCommand.finalize_options(self)
|
||||
self.test_suite = True
|
||||
self.test_args = [
|
||||
'--doctest-modules', '--verbose',
|
||||
'./httpie', './tests'
|
||||
@ -31,6 +30,7 @@ tests_require = [
|
||||
# https://bitbucket.org/pypa/setuptools/issue/196/
|
||||
'pytest-httpbin',
|
||||
'pytest',
|
||||
'mock',
|
||||
]
|
||||
|
||||
|
||||
@ -39,12 +39,12 @@ install_requires = [
|
||||
'Pygments>=1.5'
|
||||
]
|
||||
|
||||
### Conditional dependencies:
|
||||
# Conditional dependencies:
|
||||
|
||||
# sdist
|
||||
if not 'bdist_wheel' in sys.argv:
|
||||
if 'bdist_wheel' not in sys.argv:
|
||||
try:
|
||||
#noinspection PyUnresolvedReferences
|
||||
# noinspection PyUnresolvedReferences
|
||||
import argparse
|
||||
except ImportError:
|
||||
install_requires.append('argparse>=1.2.1')
|
||||
@ -74,9 +74,9 @@ setup(
|
||||
description=httpie.__doc__.strip(),
|
||||
long_description=long_description(),
|
||||
url='http://httpie.org/',
|
||||
download_url='https://github.com/jakubroztocil/httpie',
|
||||
download_url='https://github.com/jkbrzt/httpie',
|
||||
author=httpie.__author__,
|
||||
author_email='jakub@roztocil.name',
|
||||
author_email='jakub@roztocil.co',
|
||||
license=httpie.__licence__,
|
||||
packages=find_packages(),
|
||||
entry_points={
|
||||
|
@ -5,4 +5,4 @@ HTTPie Test Suite
|
||||
Please see `CONTRIBUTING`_.
|
||||
|
||||
|
||||
.. _CONTRIBUTING: https://github.com/jakubroztocil/httpie/blob/master/CONTRIBUTING.rst
|
||||
.. _CONTRIBUTING: https://github.com/jkbrzt/httpie/blob/master/CONTRIBUTING.rst
|
||||
|
@ -38,4 +38,3 @@ with open(BIN_FILE_PATH, 'rb') as f:
|
||||
BIN_FILE_CONTENT = f.read()
|
||||
|
||||
UNICODE = FILE_CONTENT
|
||||
|
||||
|
@ -52,11 +52,10 @@ class TestAuth:
|
||||
])
|
||||
def test_only_username_in_url(self, url):
|
||||
"""
|
||||
https://github.com/jakubroztocil/httpie/issues/242
|
||||
https://github.com/jkbrzt/httpie/issues/242
|
||||
|
||||
"""
|
||||
args = httpie.cli.parser.parse_args(args=[url], env=TestEnvironment())
|
||||
assert args.auth
|
||||
assert args.auth.key == 'username'
|
||||
assert args.auth.value == ''
|
||||
|
||||
|
@ -42,7 +42,7 @@ class TestAutoContentTypeAndAcceptHeaders:
|
||||
"""
|
||||
|
||||
def test_GET_no_data_no_auto_headers(self, httpbin):
|
||||
# https://github.com/jakubroztocil/httpie/issues/62
|
||||
# https://github.com/jkbrzt/httpie/issues/62
|
||||
r = http('GET', httpbin.url + '/headers')
|
||||
assert HTTP_OK in r
|
||||
assert r.json['headers']['Accept'] == '*/*'
|
||||
@ -59,21 +59,21 @@ class TestAutoContentTypeAndAcceptHeaders:
|
||||
r = http('POST', httpbin.url + '/post', 'a=b')
|
||||
assert HTTP_OK in r
|
||||
assert '"Accept": "application/json"' in r
|
||||
assert '"Content-Type": "application/json; charset=utf-8' in r
|
||||
assert '"Content-Type": "application/json' in r
|
||||
|
||||
def test_GET_with_data_auto_JSON_headers(self, httpbin):
|
||||
# JSON headers should automatically be set also for GET with data.
|
||||
r = http('POST', httpbin.url + '/post', 'a=b')
|
||||
assert HTTP_OK in r
|
||||
assert '"Accept": "application/json"' in r, r
|
||||
assert '"Content-Type": "application/json; charset=utf-8' in r
|
||||
assert '"Content-Type": "application/json' in r
|
||||
|
||||
def test_POST_explicit_JSON_auto_JSON_accept(self, httpbin):
|
||||
r = http('--json', 'POST', httpbin.url + '/post')
|
||||
assert HTTP_OK in r
|
||||
assert r.json['headers']['Accept'] == 'application/json'
|
||||
# Make sure Content-Type gets set even with no data.
|
||||
# https://github.com/jakubroztocil/httpie/issues/137
|
||||
# https://github.com/jkbrzt/httpie/issues/137
|
||||
assert 'application/json' in r.json['headers']['Content-Type']
|
||||
|
||||
def test_GET_explicit_JSON_explicit_headers(self, httpbin):
|
||||
|
@ -9,7 +9,7 @@ from utils import TESTS_ROOT
|
||||
|
||||
def has_docutils():
|
||||
try:
|
||||
#noinspection PyUnresolvedReferences
|
||||
# noinspection PyUnresolvedReferences
|
||||
import docutils
|
||||
return True
|
||||
except ImportError:
|
||||
@ -32,8 +32,8 @@ assert filenames
|
||||
def test_rst_file_syntax(filename):
|
||||
p = subprocess.Popen(
|
||||
['rst2pseudoxml.py', '--report=1', '--exit-status=1', filename],
|
||||
stderr=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE
|
||||
stderr=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE
|
||||
)
|
||||
err = p.communicate()[1]
|
||||
assert p.returncode == 0, err
|
||||
|
48
tests/test_errors.py
Normal file
48
tests/test_errors.py
Normal file
@ -0,0 +1,48 @@
|
||||
import mock
|
||||
from pytest import raises
|
||||
from requests import Request, Timeout
|
||||
from requests.exceptions import ConnectionError
|
||||
|
||||
from httpie.core import main
|
||||
|
||||
error_msg = None
|
||||
|
||||
|
||||
@mock.patch('httpie.core.get_response')
|
||||
def test_error(get_response):
|
||||
def error(msg, *args, **kwargs):
|
||||
global error_msg
|
||||
error_msg = msg % args
|
||||
|
||||
exc = ConnectionError('Connection aborted')
|
||||
exc.request = Request(method='GET', url='http://www.google.com')
|
||||
get_response.side_effect = exc
|
||||
ret = main(['--ignore-stdin', 'www.google.com'], error=error)
|
||||
assert ret == 1
|
||||
assert error_msg == (
|
||||
'ConnectionError: '
|
||||
'Connection aborted while doing GET request to URL: '
|
||||
'http://www.google.com')
|
||||
|
||||
|
||||
@mock.patch('httpie.core.get_response')
|
||||
def test_error_traceback(get_response):
|
||||
exc = ConnectionError('Connection aborted')
|
||||
exc.request = Request(method='GET', url='http://www.google.com')
|
||||
get_response.side_effect = exc
|
||||
with raises(ConnectionError):
|
||||
ret = main(['--ignore-stdin', '--traceback', 'www.google.com'])
|
||||
|
||||
|
||||
@mock.patch('httpie.core.get_response')
|
||||
def test_timeout(get_response):
|
||||
def error(msg, *args, **kwargs):
|
||||
global error_msg
|
||||
error_msg = msg % args
|
||||
|
||||
exc = Timeout('Request timed out')
|
||||
exc.request = Request(method='GET', url='http://www.google.com')
|
||||
get_response.side_effect = exc
|
||||
ret = main(['--ignore-stdin', 'www.google.com'], error=error)
|
||||
assert ret == 2
|
||||
assert error_msg == 'Request timed out (30s).'
|
@ -18,7 +18,7 @@ class TestHTTPie:
|
||||
def test_help(self):
|
||||
r = http('--help', error_exit_ok=True)
|
||||
assert r.exit_status == httpie.ExitStatus.OK
|
||||
assert 'https://github.com/jakubroztocil/httpie/issues' in r
|
||||
assert 'https://github.com/jkbrzt/httpie/issues' in r
|
||||
|
||||
def test_version(self):
|
||||
r = http('--version', error_exit_ok=True)
|
||||
|
@ -13,7 +13,7 @@ class TestVerboseFlag:
|
||||
assert r.count('__test__') == 2
|
||||
|
||||
def test_verbose_form(self, httpbin):
|
||||
# https://github.com/jakubroztocil/httpie/issues/53
|
||||
# https://github.com/jkbrzt/httpie/issues/53
|
||||
r = http('--verbose', '--form', 'POST', httpbin.url + '/post',
|
||||
'A=B', 'C=D')
|
||||
assert HTTP_OK in r
|
||||
|
@ -7,7 +7,7 @@ from httpie.compat import is_windows
|
||||
|
||||
def test_Host_header_overwrite(httpbin):
|
||||
"""
|
||||
https://github.com/jakubroztocil/httpie/issues/235
|
||||
https://github.com/jkbrzt/httpie/issues/235
|
||||
|
||||
"""
|
||||
host = 'httpbin.org'
|
||||
@ -21,7 +21,7 @@ def test_Host_header_overwrite(httpbin):
|
||||
@pytest.mark.skipif(is_windows, reason='Unix-only')
|
||||
def test_output_devnull(httpbin):
|
||||
"""
|
||||
https://github.com/jakubroztocil/httpie/issues/252
|
||||
https://github.com/jkbrzt/httpie/issues/252
|
||||
|
||||
"""
|
||||
http('--output=/dev/null', httpbin + '/get')
|
||||
|
@ -1,6 +1,9 @@
|
||||
# coding=utf-8
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
from httpie.plugins.builtin import HTTPBasicAuth
|
||||
from utils import TestEnvironment, mk_config_dir, http, HTTP_OK, \
|
||||
@ -61,17 +64,20 @@ class TestSessionFlow(SessionTestBase):
|
||||
def test_session_update(self, httpbin):
|
||||
self.start_session(httpbin)
|
||||
# Get a response to a request from the original session.
|
||||
r2 = http('--session=test', 'GET', httpbin.url + '/get', env=self.env())
|
||||
r2 = http('--session=test', 'GET', httpbin.url + '/get',
|
||||
env=self.env())
|
||||
assert HTTP_OK in r2
|
||||
|
||||
# Make a request modifying the session data.
|
||||
r3 = http('--follow', '--session=test', '--auth=username:password2',
|
||||
'GET', httpbin.url + '/cookies/set?hello=world2', 'Hello:World2',
|
||||
'GET', httpbin.url + '/cookies/set?hello=world2',
|
||||
'Hello:World2',
|
||||
env=self.env())
|
||||
assert HTTP_OK in r3
|
||||
|
||||
# Get a response to a request from the updated session.
|
||||
r4 = http('--session=test', 'GET', httpbin.url + '/get', env=self.env())
|
||||
r4 = http('--session=test', 'GET', httpbin.url + '/get',
|
||||
env=self.env())
|
||||
assert HTTP_OK in r4
|
||||
assert r4.json['headers']['Hello'] == 'World2'
|
||||
assert r4.json['headers']['Cookie'] == 'hello=world2'
|
||||
@ -81,7 +87,8 @@ class TestSessionFlow(SessionTestBase):
|
||||
def test_session_read_only(self, httpbin):
|
||||
self.start_session(httpbin)
|
||||
# Get a response from the original session.
|
||||
r2 = http('--session=test', 'GET', httpbin.url + '/get', env=self.env())
|
||||
r2 = http('--session=test', 'GET', httpbin.url + '/get',
|
||||
env=self.env())
|
||||
assert HTTP_OK in r2
|
||||
|
||||
# Make a request modifying the session data but
|
||||
@ -93,7 +100,8 @@ class TestSessionFlow(SessionTestBase):
|
||||
assert HTTP_OK in r3
|
||||
|
||||
# Get a response from the updated session.
|
||||
r4 = http('--session=test', 'GET', httpbin.url + '/get', env=self.env())
|
||||
r4 = http('--session=test', 'GET', httpbin.url + '/get',
|
||||
env=self.env())
|
||||
assert HTTP_OK in r4
|
||||
|
||||
# Origin can differ on Travis.
|
||||
@ -114,8 +122,8 @@ class TestSession(SessionTestBase):
|
||||
'If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT',
|
||||
env=self.env())
|
||||
assert HTTP_OK in r1
|
||||
|
||||
r2 = http('--session=test', 'GET', httpbin.url + '/get', env=self.env())
|
||||
r2 = http('--session=test', 'GET', httpbin.url + '/get',
|
||||
env=self.env())
|
||||
assert HTTP_OK in r2
|
||||
assert no_content_type(r2.json['headers'])
|
||||
assert 'If-Unmodified-Since' not in r2.json['headers']
|
||||
@ -132,6 +140,10 @@ class TestSession(SessionTestBase):
|
||||
assert HTTP_OK in r2
|
||||
assert r2.json['headers']['Foo'] == 'Bar'
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.version_info >= (3,),
|
||||
reason="This test fails intermittently on Python 3 - "
|
||||
"see https://github.com/jkbrzt/httpie/issues/282")
|
||||
def test_session_unicode(self, httpbin):
|
||||
self.start_session(httpbin)
|
||||
|
||||
@ -152,7 +164,7 @@ class TestSession(SessionTestBase):
|
||||
|
||||
def test_session_default_header_value_overwritten(self, httpbin):
|
||||
self.start_session(httpbin)
|
||||
# https://github.com/jakubroztocil/httpie/issues/180
|
||||
# https://github.com/jkbrzt/httpie/issues/180
|
||||
r1 = http('--session=test',
|
||||
httpbin.url + '/headers', 'User-Agent:custom',
|
||||
env=self.env())
|
||||
|
@ -30,7 +30,7 @@ class TestMultipartFormDataFileUpload:
|
||||
'test-file@%s' % FILE_PATH_ARG)
|
||||
assert HTTP_OK in r
|
||||
assert r.count('Content-Disposition: form-data; name="test-file";'
|
||||
' filename="%s"' % os.path.basename(FILE_PATH)) == 2
|
||||
' filename="%s"' % os.path.basename(FILE_PATH)) == 2
|
||||
# Should be 4, but is 3 because httpbin
|
||||
# doesn't seem to support filed field lists
|
||||
assert r.count(FILE_CONTENT) in [3, 4]
|
||||
|
Reference in New Issue
Block a user