mirror of
https://github.com/httpie/cli.git
synced 2025-08-16 09:18:27 +02:00
Compare commits
64 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 | |||
f855de16c2 | |||
7f8adad313 |
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
|
@ -1,8 +1,8 @@
|
|||||||
# https://travis-ci.org/jakubroztocil/httpie
|
# https://travis-ci.org/jkbrzt/httpie
|
||||||
sudo: false
|
sudo: false
|
||||||
os:
|
os:
|
||||||
- linux
|
- linux
|
||||||
- osx
|
# - osx
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- NEWEST_PYTHON=3.4
|
- NEWEST_PYTHON=3.4
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
HTTPie authors
|
HTTPie authors
|
||||||
==============
|
==============
|
||||||
|
|
||||||
* `Jakub Roztocil <https://github.com/jakubroztocil>`_
|
* `Jakub Roztocil <https://github.com/jkbrzt>`_
|
||||||
|
|
||||||
|
|
||||||
Patches and ideas
|
Patches and ideas
|
||||||
@ -32,3 +32,5 @@ Patches and ideas
|
|||||||
* `Nathan LaFreniere <https://github.com/nlf>`_
|
* `Nathan LaFreniere <https://github.com/nlf>`_
|
||||||
* `Matthias Lehmann <https://github.com/matleh>`_
|
* `Matthias Lehmann <https://github.com/matleh>`_
|
||||||
* `Dennis Brakhane <https://github.com/brakhane>`_
|
* `Dennis Brakhane <https://github.com/brakhane>`_
|
||||||
|
* `Matt Layman <https://github.com/mblayman>`_
|
||||||
|
* `Edward Yang <https://github.com/honorabrutroll>`_
|
||||||
|
@ -6,9 +6,16 @@ This document records all notable changes to `HTTPie <http://httpie.org>`_.
|
|||||||
This project adheres to `Semantic Versioning <http://semver.org/>`_.
|
This project adheres to `Semantic Versioning <http://semver.org/>`_.
|
||||||
|
|
||||||
|
|
||||||
`1.0.0-dev`_ (Unreleased)
|
`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)
|
`0.9.2`_ (2015-02-24)
|
||||||
@ -24,7 +31,7 @@ This project adheres to `Semantic Versioning <http://semver.org/>`_.
|
|||||||
|
|
||||||
* Added support for Requests transport adapter plugins
|
* Added support for Requests transport adapter plugins
|
||||||
(see `httpie-unixsocket <https://github.com/msabramo/httpie-unixsocket>`_
|
(see `httpie-unixsocket <https://github.com/msabramo/httpie-unixsocket>`_
|
||||||
and `httpie-http2 <https://github.com/jakubroztocil/httpie-http2>`_)
|
and `httpie-http2 <https://github.com/jkbrzt/httpie-http2>`_)
|
||||||
|
|
||||||
|
|
||||||
`0.9.0`_ (2015-01-31)
|
`0.9.0`_ (2015-01-31)
|
||||||
@ -228,25 +235,26 @@ This project adheres to `Semantic Versioning <http://semver.org/>`_.
|
|||||||
* Initial public release
|
* Initial public release
|
||||||
|
|
||||||
|
|
||||||
.. _`0.1`: https://github.com/jakubroztocil/httpie/commit/b966efa
|
.. _`0.1`: https://github.com/jkbrzt/httpie/commit/b966efa
|
||||||
.. _0.1.4: https://github.com/jakubroztocil/httpie/compare/b966efa...0.1.4
|
.. _0.1.4: https://github.com/jkbrzt/httpie/compare/b966efa...0.1.4
|
||||||
.. _0.1.5: https://github.com/jakubroztocil/httpie/compare/0.1.4...0.1.5
|
.. _0.1.5: https://github.com/jkbrzt/httpie/compare/0.1.4...0.1.5
|
||||||
.. _0.1.6: https://github.com/jakubroztocil/httpie/compare/0.1.5...0.1.6
|
.. _0.1.6: https://github.com/jkbrzt/httpie/compare/0.1.5...0.1.6
|
||||||
.. _0.2.0: https://github.com/jakubroztocil/httpie/compare/0.1.6...0.2.0
|
.. _0.2.0: https://github.com/jkbrzt/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.1: https://github.com/jkbrzt/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.2: https://github.com/jkbrzt/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.5: https://github.com/jkbrzt/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.6: https://github.com/jkbrzt/httpie/compare/0.2.5...0.2.6
|
||||||
.. _0.2.7: https://github.com/jakubroztocil/httpie/compare/0.2.5...0.2.7
|
.. _0.2.7: https://github.com/jkbrzt/httpie/compare/0.2.5...0.2.7
|
||||||
.. _0.3.0: https://github.com/jakubroztocil/httpie/compare/0.2.7...0.3.0
|
.. _0.3.0: https://github.com/jkbrzt/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.0: https://github.com/jkbrzt/httpie/compare/0.3.0...0.4.0
|
||||||
.. _0.4.1: https://github.com/jakubroztocil/httpie/compare/0.4.0...0.4.1
|
.. _0.4.1: https://github.com/jkbrzt/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.0: https://github.com/jkbrzt/httpie/compare/0.4.1...0.5.0
|
||||||
.. _0.5.1: https://github.com/jakubroztocil/httpie/compare/0.5.0...0.5.1
|
.. _0.5.1: https://github.com/jkbrzt/httpie/compare/0.5.0...0.5.1
|
||||||
.. _0.6.0: https://github.com/jakubroztocil/httpie/compare/0.5.1...0.6.0
|
.. _0.6.0: https://github.com/jkbrzt/httpie/compare/0.5.1...0.6.0
|
||||||
.. _0.7.1: https://github.com/jakubroztocil/httpie/compare/0.6.0...0.7.1
|
.. _0.7.1: https://github.com/jkbrzt/httpie/compare/0.6.0...0.7.1
|
||||||
.. _0.8.0: https://github.com/jakubroztocil/httpie/compare/0.7.1...0.8.0
|
.. _0.8.0: https://github.com/jkbrzt/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.0: https://github.com/jkbrzt/httpie/compare/0.8.0...0.9.0
|
||||||
.. _0.9.1: https://github.com/jakubroztocil/httpie/compare/0.9.0...0.9.1
|
.. _0.9.1: https://github.com/jkbrzt/httpie/compare/0.9.0...0.9.1
|
||||||
.. _0.9.2: https://github.com/jakubroztocil/httpie/compare/0.9.1...0.9.2
|
.. _0.9.2: https://github.com/jkbrzt/httpie/compare/0.9.1...0.9.2
|
||||||
.. _1.0.0-dev: https://github.com/jakubroztocil/httpie/compare/0.9.2...master
|
.. _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
|
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
|
also help by using the development version of HTTPie and reporting any bugs you
|
||||||
might encounter.
|
might encounter.
|
||||||
|
|
||||||
@ -87,9 +87,9 @@ Don't forget to add yourself to `AUTHORS.rst`_.
|
|||||||
|
|
||||||
|
|
||||||
.. _Tox: http://tox.testrun.org
|
.. _Tox: http://tox.testrun.org
|
||||||
.. _supported Python environments: https://github.com/jakubroztocil/httpie/blob/master/tox.ini
|
.. _supported Python environments: https://github.com/jkbrzt/httpie/blob/master/tox.ini
|
||||||
.. _existing issues: https://github.com/jakubroztocil/httpie/issues?state=open
|
.. _existing issues: https://github.com/jkbrzt/httpie/issues?state=open
|
||||||
.. _AUTHORS.rst: https://github.com/jakubroztocil/httpie/blob/master/AUTHORS.rst
|
.. _AUTHORS.rst: https://github.com/jkbrzt/httpie/blob/master/AUTHORS.rst
|
||||||
.. _pytest: http://pytest.org/
|
.. _pytest: http://pytest.org/
|
||||||
.. _Style Guide for Python Code: http://python.org/dev/peps/pep-0008/
|
.. _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.co>
|
Copyright © 2012-2015 Jakub Roztocil <jakub@roztocil.co>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
75
README.rst
75
README.rst
@ -2,15 +2,15 @@
|
|||||||
HTTPie: a CLI, cURL-like tool for humans
|
HTTPie: a CLI, cURL-like tool for humans
|
||||||
****************************************
|
****************************************
|
||||||
|
|
||||||
HTTPie (pronounced *aych-tee-tee-pie*) is a **command line HTTP client**. Its
|
HTTPie (pronounced *aitch-tee-tee-pie*) is a **command line HTTP client**.
|
||||||
goal is to make CLI interaction with web services as **human-friendly** as
|
Its goal is to make CLI interaction with web services as **human-friendly**
|
||||||
possible. It provides a simple ``http`` command that allows for sending
|
as possible. It provides a simple ``http`` command that allows for sending
|
||||||
arbitrary HTTP requests using a simple and natural syntax, and displays
|
arbitrary HTTP requests using a simple and natural syntax, and displays
|
||||||
colorized output. HTTPie can be used for **testing, debugging**, and
|
colorized output. HTTPie can be used for **testing, debugging**, and
|
||||||
generally **interacting** with HTTP servers.
|
generally **interacting** with HTTP servers.
|
||||||
|
|
||||||
|
|
||||||
.. image:: httpie.png
|
.. image:: https://raw.githubusercontent.com/jkbrzt/httpie/master/httpie.png
|
||||||
:alt: HTTPie compared to cURL
|
:alt: HTTPie compared to cURL
|
||||||
:width: 679
|
:width: 679
|
||||||
:height: 781
|
:height: 781
|
||||||
@ -58,9 +58,6 @@ Main Features
|
|||||||
Installation
|
Installation
|
||||||
============
|
============
|
||||||
|
|
||||||
--------------
|
|
||||||
Stable version
|
|
||||||
--------------
|
|
||||||
|
|
||||||
On **Mac OS X**, HTTPie can be installed via `Homebrew <http://brew.sh/>`_:
|
On **Mac OS X**, HTTPie can be installed via `Homebrew <http://brew.sh/>`_:
|
||||||
|
|
||||||
@ -70,7 +67,7 @@ On **Mac OS X**, HTTPie can be installed via `Homebrew <http://brew.sh/>`_:
|
|||||||
|
|
||||||
|
|
||||||
Most **Linux** distributions provide a package that can be installed using the
|
Most **Linux** distributions provide a package that can be installed using the
|
||||||
the system package manager, e.g.:
|
system package manager, e.g.:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
@ -109,7 +106,7 @@ The **latest development version** can be installed directly from GitHub:
|
|||||||
$ brew install httpie --HEAD
|
$ brew install httpie --HEAD
|
||||||
|
|
||||||
# Universal
|
# Universal
|
||||||
$ pip install --upgrade https://github.com/jakubroztocil/httpie/tarball/master
|
$ pip install --upgrade https://github.com/jkbrzt/httpie/tarball/master
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -162,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
|
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`_:
|
with `authentication`_:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. 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`_:
|
Upload a file using `redirected input`_:
|
||||||
@ -280,7 +277,7 @@ If the port is omitted, then port 80 is assumed.
|
|||||||
GET / HTTP/1.1
|
GET / HTTP/1.1
|
||||||
Host: localhost
|
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
|
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 ``&``
|
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
|
separators. To search for ``HTTPie`` on Google Images you could use this
|
||||||
@ -318,7 +315,7 @@ their type is distinguished only by the separator used:
|
|||||||
+-----------------------+-----------------------------------------------------+
|
+-----------------------+-----------------------------------------------------+
|
||||||
| URL parameters | Appends the given name/value pair as a query |
|
| URL parameters | Appends the given name/value pair as a query |
|
||||||
| ``name==value`` | string parameter to the URL. |
|
| ``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 |
|
| Data Fields | Request data fields to be serialized as a JSON |
|
||||||
| ``field=value``, | object (default), or to be form-encoded |
|
| ``field=value``, | object (default), or to be form-encoded |
|
||||||
@ -449,7 +446,8 @@ Regular Forms
|
|||||||
|
|
||||||
.. code-block:: bash
|
.. 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
|
.. code-block:: http
|
||||||
@ -494,7 +492,8 @@ To set custom headers you can use the ``Header:Value`` notation:
|
|||||||
|
|
||||||
.. code-block:: bash
|
.. 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
|
.. code-block:: http
|
||||||
@ -535,7 +534,7 @@ The currently supported authentication schemes are Basic and Digest
|
|||||||
the argument. Or, if you only specify a username
|
the argument. Or, if you only specify a username
|
||||||
(``-a username``), you'll be prompted for
|
(``-a username``), you'll be prompted for
|
||||||
the password before the request is sent.
|
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
|
The ``username:password@hostname`` URL syntax is
|
||||||
supported as well (but credentials passed via ``-a``
|
supported as well (but credentials passed via ``-a``
|
||||||
have higher priority).
|
have higher priority).
|
||||||
@ -588,11 +587,13 @@ Authorization information from your ``~/.netrc`` file is honored as well:
|
|||||||
Auth Plugins
|
Auth Plugins
|
||||||
------------
|
------------
|
||||||
|
|
||||||
* `httpie-oauth <https://github.com/jakubroztocil/httpie-oauth>`_: OAuth
|
* `httpie-oauth <https://github.com/jkbrzt/httpie-oauth>`_: OAuth
|
||||||
* `httpie-ntlm <https://github.com/jakubroztocil/httpie-ntlm>`_: NTLM (NT LAN Manager)
|
* `httpie-ntlm <https://github.com/jkbrzt/httpie-ntlm>`_: NTLM (NT LAN Manager)
|
||||||
* `httpie-negotiate <https://github.com/ndzou/httpie-negotiate>`_: SPNEGO (GSS Negotiate)
|
* `httpie-negotiate <https://github.com/ndzou/httpie-negotiate>`_: SPNEGO (GSS Negotiate)
|
||||||
* `requests-hawk <https://github.com/mozilla-services/requests-hawk>`_: Hawk
|
* `requests-hawk <https://github.com/mozilla-services/requests-hawk>`_: Hawk
|
||||||
* `httpie-api-auth <https://github.com/pd/httpie-api-auth>`_: ApiAuth
|
* `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)
|
||||||
|
|
||||||
|
|
||||||
=======
|
=======
|
||||||
@ -824,7 +825,7 @@ You can even pipe web services together using HTTPie:
|
|||||||
|
|
||||||
.. code-block:: bash
|
.. 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:
|
You can use ``cat`` to enter multiline data on the terminal:
|
||||||
@ -894,7 +895,7 @@ Colors and Formatting
|
|||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
Syntax highlighting is applied to HTTP headers and bodies (where it makes
|
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
|
if you don't like the default one (see ``$ http --help`` for the possible
|
||||||
values).
|
values).
|
||||||
|
|
||||||
@ -1008,19 +1009,19 @@ is being saved to a file.
|
|||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
$ http --download https://github.com/jakubroztocil/httpie/tarball/master
|
$ http --download https://github.com/jkbrzt/httpie/tarball/master
|
||||||
|
|
||||||
.. code-block:: http
|
.. code-block:: http
|
||||||
|
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
Connection: keep-alive
|
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-Length: 505530
|
||||||
Content-Type: application/x-gzip
|
Content-Type: application/x-gzip
|
||||||
Server: GitHub.com
|
Server: GitHub.com
|
||||||
Vary: Accept-Encoding
|
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
|
/ 21.01% 104.00 kB 47.55 kB/s 0:00:08 ETA
|
||||||
|
|
||||||
|
|
||||||
@ -1034,7 +1035,7 @@ headers and progress are still shown in the terminal:
|
|||||||
|
|
||||||
.. code-block:: bash
|
.. 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
|
If ``--output, -o`` is specified, you can resume a partial download using the
|
||||||
@ -1283,7 +1284,7 @@ Authors
|
|||||||
=======
|
=======
|
||||||
|
|
||||||
|
|
||||||
`Jakub Roztocil`_ (`@jakubroztocil`_) created HTTPie and `these fine people`_
|
`Jakub Roztocil`_ (`@jkbrzt`_) created HTTPie and `these fine people`_
|
||||||
have contributed.
|
have contributed.
|
||||||
|
|
||||||
|
|
||||||
@ -1298,21 +1299,21 @@ Please see `claudiatd/httpie-artwork`_
|
|||||||
Contribute
|
Contribute
|
||||||
==========
|
==========
|
||||||
|
|
||||||
Please see `CONTRIBUTING <https://github.com/jakubroztocil/httpie/blob/master/CONTRIBUTING.rst>`_.
|
Please see `CONTRIBUTING <https://github.com/jkbrzt/httpie/blob/master/CONTRIBUTING.rst>`_.
|
||||||
|
|
||||||
|
|
||||||
==========
|
==========
|
||||||
Change Log
|
Change Log
|
||||||
==========
|
==========
|
||||||
|
|
||||||
Please see `CHANGELOG <https://github.com/jakubroztocil/httpie/blob/master/CHANGELOG.rst>`_.
|
Please see `CHANGELOG <https://github.com/jkbrzt/httpie/blob/master/CHANGELOG.rst>`_.
|
||||||
|
|
||||||
|
|
||||||
=======
|
=======
|
||||||
Licence
|
Licence
|
||||||
=======
|
=======
|
||||||
|
|
||||||
Please see `LICENSE <https://github.com/jakubroztocil/httpie/blob/master/LICENSE>`_.
|
Please see `LICENSE <https://github.com/jkbrzt/httpie/blob/master/LICENSE>`_.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1320,9 +1321,9 @@ Please see `LICENSE <https://github.com/jakubroztocil/httpie/blob/master/LICENSE
|
|||||||
.. _Pygments: http://pygments.org/
|
.. _Pygments: http://pygments.org/
|
||||||
.. _pip: http://www.pip-installer.org/en/latest/index.html
|
.. _pip: http://www.pip-installer.org/en/latest/index.html
|
||||||
.. _Github API: http://developer.github.com/v3/issues/comments/#create-a-comment
|
.. _Github API: http://developer.github.com/v3/issues/comments/#create-a-comment
|
||||||
.. _these fine people: https://github.com/jakubroztocil/httpie/contributors
|
.. _these fine people: https://github.com/jkbrzt/httpie/contributors
|
||||||
.. _Jakub Roztocil: http://subtleapps.com
|
.. _Jakub Roztocil: http://roztocil.co
|
||||||
.. _@jakubroztocil: https://twitter.com/jakubroztocil
|
.. _@jkbrzt: https://twitter.com/jkbrzt
|
||||||
.. _claudiatd/httpie-artwork: https://github.com/claudiatd/httpie-artwork
|
.. _claudiatd/httpie-artwork: https://github.com/claudiatd/httpie-artwork
|
||||||
|
|
||||||
|
|
||||||
@ -1330,14 +1331,14 @@ Please see `LICENSE <https://github.com/jakubroztocil/httpie/blob/master/LICENSE
|
|||||||
:target: https://pypi.python.org/pypi/httpie
|
:target: https://pypi.python.org/pypi/httpie
|
||||||
:alt: Latest version released on PyPi
|
:alt: Latest version released on PyPi
|
||||||
|
|
||||||
.. |coverage| image:: https://img.shields.io/coveralls/jakubroztocil/httpie/master.svg?style=flat-square
|
.. |coverage| image:: https://img.shields.io/coveralls/jkbrzt/httpie/master.svg?style=flat-square
|
||||||
:target: https://coveralls.io/r/jakubroztocil/httpie?branch=master
|
:target: https://coveralls.io/r/jkbrzt/httpie?branch=master
|
||||||
:alt: Test coverage
|
:alt: Test coverage
|
||||||
|
|
||||||
.. |unix_build| image:: https://img.shields.io/travis/jakubroztocil/httpie/master.svg?style=flat-square&label=unix%20build
|
.. |unix_build| image:: https://img.shields.io/travis/jkbrzt/httpie/master.svg?style=flat-square&label=unix%20build
|
||||||
:target: http://travis-ci.org/jakubroztocil/httpie
|
:target: http://travis-ci.org/jkbrzt/httpie
|
||||||
:alt: Build status of the master branch on Mac/Linux
|
:alt: Build status of the master branch on Mac/Linux
|
||||||
|
|
||||||
.. |windows_build| image:: https://img.shields.io/appveyor/ci/jakubroztocil/httpie.svg?style=flat-square&label=windows%20build
|
.. |windows_build| image:: https://img.shields.io/appveyor/ci/jkbrzt/httpie.svg?style=flat-square&label=windows%20build
|
||||||
:target: https://ci.appveyor.com/project/jakubroztocil/httpie
|
:target: https://ci.appveyor.com/project/jkbrzt/httpie
|
||||||
:alt: Build status of the master branch on Windows
|
: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
|
build: false
|
||||||
environment:
|
environment:
|
||||||
matrix:
|
matrix:
|
||||||
@ -8,8 +8,9 @@ init:
|
|||||||
- "ECHO %PYTHON%"
|
- "ECHO %PYTHON%"
|
||||||
- ps: "ls C:/Python*"
|
- ps: "ls C:/Python*"
|
||||||
install:
|
install:
|
||||||
- ps: (new-object net.webclient).DownloadFile('https://raw.github.com/pypa/pip/master/contrib/get-pip.py', '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%/python.exe C:/get-pip.py"
|
||||||
|
- "%PYTHON%/Scripts/pip.exe install -U pip setuptools"
|
||||||
- "%PYTHON%/Scripts/pip.exe install -e ."
|
- "%PYTHON%/Scripts/pip.exe install -e ."
|
||||||
test_script:
|
test_script:
|
||||||
- "%PYTHON%/Scripts/pip.exe --version"
|
- "%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" ) )
|
||||||
|
}
|
@ -3,7 +3,7 @@ HTTPie - a CLI, cURL-like tool for humans.
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
__author__ = 'Jakub Roztocil'
|
__author__ = 'Jakub Roztocil'
|
||||||
__version__ = '0.9.2'
|
__version__ = '0.9.3'
|
||||||
__licence__ = 'BSD'
|
__licence__ = 'BSD'
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ NOTE: the CLI interface may change before reaching v1.0.
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
from textwrap import dedent, wrap
|
from textwrap import dedent, wrap
|
||||||
#noinspection PyCompatibility
|
# noinspection PyCompatibility
|
||||||
from argparse import (RawDescriptionHelpFormatter, FileType,
|
from argparse import (RawDescriptionHelpFormatter, FileType,
|
||||||
OPTIONAL, ZERO_OR_MORE, SUPPRESS)
|
OPTIONAL, ZERO_OR_MORE, SUPPRESS)
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ parser = Parser(
|
|||||||
|
|
||||||
Suggestions and bug reports are greatly appreciated:
|
Suggestions and bug reports are greatly appreciated:
|
||||||
|
|
||||||
https://github.com/jakubroztocil/httpie/issues
|
https://github.com/jkbrzt/httpie/issues
|
||||||
|
|
||||||
""")
|
""")
|
||||||
)
|
)
|
||||||
|
@ -11,8 +11,15 @@ from httpie.compat import str
|
|||||||
from httpie.plugins import plugin_manager
|
from httpie.plugins import plugin_manager
|
||||||
|
|
||||||
|
|
||||||
# https://urllib3.readthedocs.org/en/latest/security.html
|
try:
|
||||||
urllib3.disable_warnings()
|
# 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'
|
FORM = 'application/x-www-form-urlencoded; charset=utf-8'
|
||||||
@ -22,7 +29,7 @@ DEFAULT_UA = 'HTTPie/%s' % __version__
|
|||||||
|
|
||||||
def get_requests_session():
|
def get_requests_session():
|
||||||
requests_session = 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()
|
transport_plugin = cls()
|
||||||
requests_session.mount(prefix=transport_plugin.prefix,
|
requests_session.mount(prefix=transport_plugin.prefix,
|
||||||
adapter=transport_plugin.get_adapter())
|
adapter=transport_plugin.get_adapter())
|
||||||
@ -52,13 +59,13 @@ def get_response(args, config_dir):
|
|||||||
|
|
||||||
|
|
||||||
def dump_request(kwargs):
|
def dump_request(kwargs):
|
||||||
sys.stderr.write('\n>>> requests.request(%s)\n\n'
|
sys.stderr.write('\n>>> requests.request(**%s)\n\n'
|
||||||
% pformat(kwargs))
|
% pformat(kwargs))
|
||||||
|
|
||||||
|
|
||||||
def encode_headers(headers):
|
def encode_headers(headers):
|
||||||
# This allows for unicode headers which is non-standard but practical.
|
# 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(
|
return dict(
|
||||||
(name, value.encode('utf8') if isinstance(value, str) else value)
|
(name, value.encode('utf8') if isinstance(value, str) else value)
|
||||||
for name, value in headers.items()
|
for name, value in headers.items()
|
||||||
@ -92,7 +99,7 @@ def get_requests_kwargs(args, base_headers=None):
|
|||||||
# Serialize JSON data, if needed.
|
# Serialize JSON data, if needed.
|
||||||
data = args.data
|
data = args.data
|
||||||
auto_json = data and not args.form
|
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:
|
if data:
|
||||||
data = json.dumps(data)
|
data = json.dumps(data)
|
||||||
else:
|
else:
|
||||||
|
@ -5,13 +5,11 @@ Python 2.6, 2.7, and 3.x compatibility.
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
# Taken from `requests.compat`
|
is_py2 = sys.version_info[0] == 2
|
||||||
_ver = sys.version_info
|
is_py26 = sys.version_info[:2] == (2, 6)
|
||||||
is_py2 = (_ver[0] == 2)
|
is_py27 = sys.version_info[:2] == (2, 7)
|
||||||
is_py26 = (is_py2 and _ver[1] == 6)
|
is_py3 = sys.version_info[0] == 3
|
||||||
is_py27 = (is_py2 and _ver[1] == 7)
|
is_pypy = 'pypy' in sys.version.lower()
|
||||||
is_py3 = (_ver[0] == 3)
|
|
||||||
is_pypy = ('pypy' in _ver)
|
|
||||||
is_windows = 'win32' in str(sys.platform).lower()
|
is_windows = 'win32' in str(sys.platform).lower()
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ class BaseConfigDict(dict):
|
|||||||
class Config(BaseConfigDict):
|
class Config(BaseConfigDict):
|
||||||
|
|
||||||
name = 'config'
|
name = 'config'
|
||||||
helpurl = 'https://github.com/jakubroztocil/httpie#config'
|
helpurl = 'https://github.com/jkbrzt/httpie#config'
|
||||||
about = 'HTTPie configuration file'
|
about = 'HTTPie configuration file'
|
||||||
|
|
||||||
DEFAULTS = {
|
DEFAULTS = {
|
||||||
|
@ -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``.
|
"""Run the main program and write the output to ``env.stdout``.
|
||||||
|
|
||||||
Return exit status code.
|
Return exit status code.
|
||||||
@ -81,11 +81,14 @@ def main(args=sys.argv[1:], env=Environment()):
|
|||||||
if env.config.default_options:
|
if env.config.default_options:
|
||||||
args = env.config.default_options + args
|
args = env.config.default_options + args
|
||||||
|
|
||||||
def error(msg, *args, **kwargs):
|
def _error(msg, *args, **kwargs):
|
||||||
msg = msg % args
|
msg = msg % args
|
||||||
level = kwargs.get('level', 'error')
|
level = kwargs.get('level', 'error')
|
||||||
env.stderr.write('\nhttp: %s: %s\n' % (level, msg))
|
env.stderr.write('\nhttp: %s: %s\n' % (level, msg))
|
||||||
|
|
||||||
|
if error is None:
|
||||||
|
error = _error
|
||||||
|
|
||||||
debug = '--debug' in args
|
debug = '--debug' in args
|
||||||
traceback = debug or '--traceback' in args
|
traceback = debug or '--traceback' in args
|
||||||
exit_status = ExitStatus.OK
|
exit_status = ExitStatus.OK
|
||||||
@ -183,7 +186,13 @@ def main(args=sys.argv[1:], env=Environment()):
|
|||||||
# Network errors vs. bugs, etc.
|
# Network errors vs. bugs, etc.
|
||||||
if traceback:
|
if traceback:
|
||||||
raise
|
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
|
exit_status = ExitStatus.ERROR
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
@ -104,7 +104,7 @@ def filename_from_content_disposition(content_disposition):
|
|||||||
:return: the filename if present and valid, otherwise `None`
|
: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)
|
msg = Message('Content-Disposition: %s' % content_disposition)
|
||||||
filename = msg.get_filename()
|
filename = msg.get_filename()
|
||||||
|
@ -13,7 +13,7 @@ from collections import namedtuple, Iterable
|
|||||||
from argparse import ArgumentParser, ArgumentTypeError, ArgumentError
|
from argparse import ArgumentParser, ArgumentTypeError, ArgumentError
|
||||||
|
|
||||||
# TODO: Use MultiDict for headers once added to `requests`.
|
# 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 requests.structures import CaseInsensitiveDict
|
||||||
|
|
||||||
from httpie.compat import OrderedDict, urlsplit, str, is_pypy, is_py27
|
from httpie.compat import OrderedDict, urlsplit, str, is_pypy, is_py27
|
||||||
@ -303,8 +303,8 @@ class Parser(ArgumentParser):
|
|||||||
# Infer the method
|
# Infer the method
|
||||||
has_data = (
|
has_data = (
|
||||||
(not self.args.ignore_stdin and not self.env.stdin_isatty)
|
(not self.args.ignore_stdin and not self.env.stdin_isatty)
|
||||||
or any(item.sep in SEP_GROUP_DATA_ITEMS
|
or any(item.sep in SEP_GROUP_DATA_ITEMS
|
||||||
for item in self.args.items)
|
for item in self.args.items)
|
||||||
)
|
)
|
||||||
self.args.method = HTTP_POST if has_data else HTTP_GET
|
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:
|
if self.args.prettify == PRETTY_STDOUT_TTY_ONLY:
|
||||||
self.args.prettify = PRETTY_MAP[
|
self.args.prettify = PRETTY_MAP[
|
||||||
'all' if self.env.stdout_isatty else 'none']
|
'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.')
|
self.error('Only terminal output can be colorized on Windows.')
|
||||||
else:
|
else:
|
||||||
# noinspection PyTypeChecker
|
# noinspection PyTypeChecker
|
||||||
@ -521,7 +522,7 @@ class AuthCredentials(KeyValue):
|
|||||||
|
|
||||||
def _getpass(self, prompt):
|
def _getpass(self, prompt):
|
||||||
# To allow mocking.
|
# To allow mocking.
|
||||||
return getpass.getpass(prompt)
|
return getpass.getpass(str(prompt))
|
||||||
|
|
||||||
def has_password(self):
|
def has_password(self):
|
||||||
return self.value is not None
|
return self.value is not None
|
||||||
@ -572,7 +573,7 @@ class RequestItemsDict(OrderedDict):
|
|||||||
else:
|
else:
|
||||||
super(RequestItemsDict, self).__init__(*args, **kwargs)
|
super(RequestItemsDict, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
#noinspection PyMethodOverriding
|
# noinspection PyMethodOverriding
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
""" If `key` is assigned more than once, `self[key]` holds a
|
""" If `key` is assigned more than once, `self[key]` holds a
|
||||||
`list` of all the values.
|
`list` of all the values.
|
||||||
|
@ -14,7 +14,7 @@ from httpie.plugins import FormatterPlugin
|
|||||||
# great and fruity seems to give the best result there.
|
# great and fruity seems to give the best result there.
|
||||||
AVAILABLE_STYLES = set(pygments.styles.STYLE_MAP.keys())
|
AVAILABLE_STYLES = set(pygments.styles.STYLE_MAP.keys())
|
||||||
AVAILABLE_STYLES.add('solarized')
|
AVAILABLE_STYLES.add('solarized')
|
||||||
DEFAULT_STYLE = 'solarized'
|
DEFAULT_STYLE = 'monokai'
|
||||||
|
|
||||||
|
|
||||||
class ColorFormatter(FormatterPlugin):
|
class ColorFormatter(FormatterPlugin):
|
||||||
|
@ -15,7 +15,7 @@ class AuthPlugin(BasePlugin):
|
|||||||
"""
|
"""
|
||||||
Base auth plugin class.
|
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
|
# 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.
|
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(
|
r.headers['Authorization'] = type(self).make_header(
|
||||||
|
@ -60,6 +60,6 @@ class PluginManager(object):
|
|||||||
if issubclass(plugin, ConverterPlugin)]
|
if issubclass(plugin, ConverterPlugin)]
|
||||||
|
|
||||||
# Adapters
|
# Adapters
|
||||||
def get_trasnsport_plugins(self):
|
def get_transport_plugins(self):
|
||||||
return [plugin for plugin in self
|
return [plugin for plugin in self
|
||||||
if issubclass(plugin, TransportPlugin)]
|
if issubclass(plugin, TransportPlugin)]
|
||||||
|
@ -75,7 +75,7 @@ def get_response(requests_session, session_name,
|
|||||||
|
|
||||||
|
|
||||||
class Session(BaseConfigDict):
|
class Session(BaseConfigDict):
|
||||||
helpurl = 'https://github.com/jakubroztocil/httpie#sessions'
|
helpurl = 'https://github.com/jkbrzt/httpie#sessions'
|
||||||
about = 'HTTPie session file'
|
about = 'HTTPie session file'
|
||||||
|
|
||||||
def __init__(self, path, *args, **kwargs):
|
def __init__(self, path, *args, **kwargs):
|
||||||
|
@ -54,4 +54,3 @@ def humanize_bytes(n, precision=2):
|
|||||||
|
|
||||||
# noinspection PyUnboundLocalVariable
|
# noinspection PyUnboundLocalVariable
|
||||||
return '%.*f %s' % (precision, n / factor, suffix)
|
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
|
tox
|
||||||
|
mock
|
||||||
pytest
|
pytest
|
||||||
pytest-cov
|
pytest-cov
|
||||||
pytest-httpbin
|
pytest-httpbin>=0.0.6
|
||||||
docutils
|
docutils
|
||||||
wheel
|
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.
|
# and runs the tests with no fancy stuff like parallel execution.
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
TestCommand.finalize_options(self)
|
TestCommand.finalize_options(self)
|
||||||
self.test_suite = True
|
|
||||||
self.test_args = [
|
self.test_args = [
|
||||||
'--doctest-modules', '--verbose',
|
'--doctest-modules', '--verbose',
|
||||||
'./httpie', './tests'
|
'./httpie', './tests'
|
||||||
@ -31,6 +30,7 @@ tests_require = [
|
|||||||
# https://bitbucket.org/pypa/setuptools/issue/196/
|
# https://bitbucket.org/pypa/setuptools/issue/196/
|
||||||
'pytest-httpbin',
|
'pytest-httpbin',
|
||||||
'pytest',
|
'pytest',
|
||||||
|
'mock',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -39,12 +39,12 @@ install_requires = [
|
|||||||
'Pygments>=1.5'
|
'Pygments>=1.5'
|
||||||
]
|
]
|
||||||
|
|
||||||
### Conditional dependencies:
|
# Conditional dependencies:
|
||||||
|
|
||||||
# sdist
|
# sdist
|
||||||
if not 'bdist_wheel' in sys.argv:
|
if 'bdist_wheel' not in sys.argv:
|
||||||
try:
|
try:
|
||||||
#noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
import argparse
|
import argparse
|
||||||
except ImportError:
|
except ImportError:
|
||||||
install_requires.append('argparse>=1.2.1')
|
install_requires.append('argparse>=1.2.1')
|
||||||
@ -74,9 +74,9 @@ setup(
|
|||||||
description=httpie.__doc__.strip(),
|
description=httpie.__doc__.strip(),
|
||||||
long_description=long_description(),
|
long_description=long_description(),
|
||||||
url='http://httpie.org/',
|
url='http://httpie.org/',
|
||||||
download_url='https://github.com/jakubroztocil/httpie',
|
download_url='https://github.com/jkbrzt/httpie',
|
||||||
author=httpie.__author__,
|
author=httpie.__author__,
|
||||||
author_email='jakub@roztocil.name',
|
author_email='jakub@roztocil.co',
|
||||||
license=httpie.__licence__,
|
license=httpie.__licence__,
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
entry_points={
|
entry_points={
|
||||||
|
@ -5,4 +5,4 @@ HTTPie Test Suite
|
|||||||
Please see `CONTRIBUTING`_.
|
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()
|
BIN_FILE_CONTENT = f.read()
|
||||||
|
|
||||||
UNICODE = FILE_CONTENT
|
UNICODE = FILE_CONTENT
|
||||||
|
|
||||||
|
@ -52,11 +52,10 @@ class TestAuth:
|
|||||||
])
|
])
|
||||||
def test_only_username_in_url(self, url):
|
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())
|
args = httpie.cli.parser.parse_args(args=[url], env=TestEnvironment())
|
||||||
assert args.auth
|
assert args.auth
|
||||||
assert args.auth.key == 'username'
|
assert args.auth.key == 'username'
|
||||||
assert args.auth.value == ''
|
assert args.auth.value == ''
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class TestAutoContentTypeAndAcceptHeaders:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def test_GET_no_data_no_auto_headers(self, httpbin):
|
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')
|
r = http('GET', httpbin.url + '/headers')
|
||||||
assert HTTP_OK in r
|
assert HTTP_OK in r
|
||||||
assert r.json['headers']['Accept'] == '*/*'
|
assert r.json['headers']['Accept'] == '*/*'
|
||||||
@ -73,7 +73,7 @@ class TestAutoContentTypeAndAcceptHeaders:
|
|||||||
assert HTTP_OK in r
|
assert HTTP_OK in r
|
||||||
assert r.json['headers']['Accept'] == 'application/json'
|
assert r.json['headers']['Accept'] == 'application/json'
|
||||||
# Make sure Content-Type gets set even with no data.
|
# 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']
|
assert 'application/json' in r.json['headers']['Content-Type']
|
||||||
|
|
||||||
def test_GET_explicit_JSON_explicit_headers(self, httpbin):
|
def test_GET_explicit_JSON_explicit_headers(self, httpbin):
|
||||||
|
@ -9,7 +9,7 @@ from utils import TESTS_ROOT
|
|||||||
|
|
||||||
def has_docutils():
|
def has_docutils():
|
||||||
try:
|
try:
|
||||||
#noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
import docutils
|
import docutils
|
||||||
return True
|
return True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -32,8 +32,8 @@ assert filenames
|
|||||||
def test_rst_file_syntax(filename):
|
def test_rst_file_syntax(filename):
|
||||||
p = subprocess.Popen(
|
p = subprocess.Popen(
|
||||||
['rst2pseudoxml.py', '--report=1', '--exit-status=1', filename],
|
['rst2pseudoxml.py', '--report=1', '--exit-status=1', filename],
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
stdout=subprocess.PIPE
|
stdout=subprocess.PIPE
|
||||||
)
|
)
|
||||||
err = p.communicate()[1]
|
err = p.communicate()[1]
|
||||||
assert p.returncode == 0, err
|
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):
|
def test_help(self):
|
||||||
r = http('--help', error_exit_ok=True)
|
r = http('--help', error_exit_ok=True)
|
||||||
assert r.exit_status == httpie.ExitStatus.OK
|
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):
|
def test_version(self):
|
||||||
r = http('--version', error_exit_ok=True)
|
r = http('--version', error_exit_ok=True)
|
||||||
|
@ -13,7 +13,7 @@ class TestVerboseFlag:
|
|||||||
assert r.count('__test__') == 2
|
assert r.count('__test__') == 2
|
||||||
|
|
||||||
def test_verbose_form(self, httpbin):
|
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',
|
r = http('--verbose', '--form', 'POST', httpbin.url + '/post',
|
||||||
'A=B', 'C=D')
|
'A=B', 'C=D')
|
||||||
assert HTTP_OK in r
|
assert HTTP_OK in r
|
||||||
|
@ -7,7 +7,7 @@ from httpie.compat import is_windows
|
|||||||
|
|
||||||
def test_Host_header_overwrite(httpbin):
|
def test_Host_header_overwrite(httpbin):
|
||||||
"""
|
"""
|
||||||
https://github.com/jakubroztocil/httpie/issues/235
|
https://github.com/jkbrzt/httpie/issues/235
|
||||||
|
|
||||||
"""
|
"""
|
||||||
host = 'httpbin.org'
|
host = 'httpbin.org'
|
||||||
@ -21,7 +21,7 @@ def test_Host_header_overwrite(httpbin):
|
|||||||
@pytest.mark.skipif(is_windows, reason='Unix-only')
|
@pytest.mark.skipif(is_windows, reason='Unix-only')
|
||||||
def test_output_devnull(httpbin):
|
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')
|
http('--output=/dev/null', httpbin + '/get')
|
||||||
|
@ -64,17 +64,20 @@ class TestSessionFlow(SessionTestBase):
|
|||||||
def test_session_update(self, httpbin):
|
def test_session_update(self, httpbin):
|
||||||
self.start_session(httpbin)
|
self.start_session(httpbin)
|
||||||
# Get a response to a request from the original session.
|
# 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
|
assert HTTP_OK in r2
|
||||||
|
|
||||||
# Make a request modifying the session data.
|
# Make a request modifying the session data.
|
||||||
r3 = http('--follow', '--session=test', '--auth=username:password2',
|
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())
|
env=self.env())
|
||||||
assert HTTP_OK in r3
|
assert HTTP_OK in r3
|
||||||
|
|
||||||
# Get a response to a request from the updated session.
|
# 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 HTTP_OK in r4
|
||||||
assert r4.json['headers']['Hello'] == 'World2'
|
assert r4.json['headers']['Hello'] == 'World2'
|
||||||
assert r4.json['headers']['Cookie'] == 'hello=world2'
|
assert r4.json['headers']['Cookie'] == 'hello=world2'
|
||||||
@ -84,7 +87,8 @@ class TestSessionFlow(SessionTestBase):
|
|||||||
def test_session_read_only(self, httpbin):
|
def test_session_read_only(self, httpbin):
|
||||||
self.start_session(httpbin)
|
self.start_session(httpbin)
|
||||||
# Get a response from the original session.
|
# 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
|
assert HTTP_OK in r2
|
||||||
|
|
||||||
# Make a request modifying the session data but
|
# Make a request modifying the session data but
|
||||||
@ -96,7 +100,8 @@ class TestSessionFlow(SessionTestBase):
|
|||||||
assert HTTP_OK in r3
|
assert HTTP_OK in r3
|
||||||
|
|
||||||
# Get a response from the updated session.
|
# 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
|
assert HTTP_OK in r4
|
||||||
|
|
||||||
# Origin can differ on Travis.
|
# Origin can differ on Travis.
|
||||||
@ -117,8 +122,8 @@ class TestSession(SessionTestBase):
|
|||||||
'If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT',
|
'If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT',
|
||||||
env=self.env())
|
env=self.env())
|
||||||
assert HTTP_OK in r1
|
assert HTTP_OK in r1
|
||||||
|
r2 = http('--session=test', 'GET', httpbin.url + '/get',
|
||||||
r2 = http('--session=test', 'GET', httpbin.url + '/get', env=self.env())
|
env=self.env())
|
||||||
assert HTTP_OK in r2
|
assert HTTP_OK in r2
|
||||||
assert no_content_type(r2.json['headers'])
|
assert no_content_type(r2.json['headers'])
|
||||||
assert 'If-Unmodified-Since' not in r2.json['headers']
|
assert 'If-Unmodified-Since' not in r2.json['headers']
|
||||||
@ -138,7 +143,7 @@ class TestSession(SessionTestBase):
|
|||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
sys.version_info >= (3,),
|
sys.version_info >= (3,),
|
||||||
reason="This test fails intermittently on Python 3 - "
|
reason="This test fails intermittently on Python 3 - "
|
||||||
"see https://github.com/jakubroztocil/httpie/issues/282")
|
"see https://github.com/jkbrzt/httpie/issues/282")
|
||||||
def test_session_unicode(self, httpbin):
|
def test_session_unicode(self, httpbin):
|
||||||
self.start_session(httpbin)
|
self.start_session(httpbin)
|
||||||
|
|
||||||
@ -159,7 +164,7 @@ class TestSession(SessionTestBase):
|
|||||||
|
|
||||||
def test_session_default_header_value_overwritten(self, httpbin):
|
def test_session_default_header_value_overwritten(self, httpbin):
|
||||||
self.start_session(httpbin)
|
self.start_session(httpbin)
|
||||||
# https://github.com/jakubroztocil/httpie/issues/180
|
# https://github.com/jkbrzt/httpie/issues/180
|
||||||
r1 = http('--session=test',
|
r1 = http('--session=test',
|
||||||
httpbin.url + '/headers', 'User-Agent:custom',
|
httpbin.url + '/headers', 'User-Agent:custom',
|
||||||
env=self.env())
|
env=self.env())
|
||||||
|
@ -30,7 +30,7 @@ class TestMultipartFormDataFileUpload:
|
|||||||
'test-file@%s' % FILE_PATH_ARG)
|
'test-file@%s' % FILE_PATH_ARG)
|
||||||
assert HTTP_OK in r
|
assert HTTP_OK in r
|
||||||
assert r.count('Content-Disposition: form-data; name="test-file";'
|
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
|
# Should be 4, but is 3 because httpbin
|
||||||
# doesn't seem to support filed field lists
|
# doesn't seem to support filed field lists
|
||||||
assert r.count(FILE_CONTENT) in [3, 4]
|
assert r.count(FILE_CONTENT) in [3, 4]
|
||||||
|
Reference in New Issue
Block a user