mirror of
https://github.com/httpie/cli.git
synced 2025-08-16 16:21:49 +02:00
Compare commits
47 Commits
Author | SHA1 | Date | |
---|---|---|---|
80a2c8266c | |||
bc742b62cf | |||
43ce0b6fa1 | |||
fb437591da | |||
b7fc89acdc | |||
2e88aa53cf | |||
9e62151bec | |||
ecc59591f1 | |||
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 | |||
753a8d04e4 | |||
3ff03524ff | |||
a5a83c5b77 | |||
9682f955b5 | |||
0d21ff022e | |||
996e314482 | |||
687a6a734d | |||
b125ce5eae | |||
92a4352f10 | |||
c0f1fb61ac | |||
17358be1ae | |||
338d39c841 | |||
530d6c5e27 |
@ -1,7 +1,11 @@
|
|||||||
# https://travis-ci.org/jakubroztocil/httpie
|
# https://travis-ci.org/jakubroztocil/httpie
|
||||||
|
sudo: false
|
||||||
os:
|
os:
|
||||||
- linux
|
- linux
|
||||||
- osx
|
- osx
|
||||||
|
env:
|
||||||
|
global:
|
||||||
|
- NEWEST_PYTHON=3.4
|
||||||
language: python
|
language: python
|
||||||
python:
|
python:
|
||||||
- 2.6
|
- 2.6
|
||||||
@ -13,5 +17,4 @@ python:
|
|||||||
script:
|
script:
|
||||||
- make
|
- make
|
||||||
after_success:
|
after_success:
|
||||||
- pip install python-coveralls
|
- if [[ $TRAVIS_PYTHON_VERSION == $NEWEST_PYTHON ]]; then pip install python-coveralls && coveralls; fi
|
||||||
- coveralls
|
|
||||||
|
252
CHANGELOG.rst
Normal file
252
CHANGELOG.rst
Normal file
@ -0,0 +1,252 @@
|
|||||||
|
==========
|
||||||
|
Change Log
|
||||||
|
==========
|
||||||
|
|
||||||
|
This document records all notable changes to `HTTPie <http://httpie.org>`_.
|
||||||
|
This project adheres to `Semantic Versioning <http://semver.org/>`_.
|
||||||
|
|
||||||
|
|
||||||
|
`1.0.0-dev`_ (Unreleased)
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
`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/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``
|
||||||
|
* 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/jakubroztocil/httpie/commit/b966efa
|
||||||
|
.. _0.1.4: https://github.com/jakubroztocil/httpie/compare/b966efa...0.1.4
|
||||||
|
.. _0.1.5: https://github.com/jakubroztocil/httpie/compare/0.1.4...0.1.5
|
||||||
|
.. _0.1.6: https://github.com/jakubroztocil/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.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
|
||||||
|
.. _0.9.2: https://github.com/jakubroztocil/httpie/compare/0.9.1...0.9.2
|
||||||
|
.. _1.0.0-dev: https://github.com/jakubroztocil/httpie/compare/0.9.2...master
|
2
LICENSE
2
LICENSE
@ -1,4 +1,4 @@
|
|||||||
Copyright © 2012 Jakub Roztocil <jakub@roztocil.name>
|
Copyright © 2012 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:
|
||||||
|
@ -1 +1,4 @@
|
|||||||
include README.rst LICENSE
|
include LICENSE
|
||||||
|
include README.rst
|
||||||
|
include CHANGELOG.rst
|
||||||
|
include AUTHORS.rst
|
||||||
|
270
README.rst
270
README.rst
@ -2,34 +2,30 @@
|
|||||||
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 *aych-tee-tee-pie*) is a **command line HTTP client**. Its
|
||||||
goal is to make CLI interaction with web services as **human-friendly** as
|
goal is to make CLI interaction with web services as **human-friendly** as
|
||||||
possible. It provides a simple ``http`` command that allows for sending
|
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 responses. 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:: https://github.com/jakubroztocil/httpie/raw/master/httpie.png
|
.. image:: httpie.png
|
||||||
:alt: HTTPie compared to cURL
|
:alt: HTTPie compared to cURL
|
||||||
:width: 835
|
:width: 679
|
||||||
:height: 835
|
:height: 781
|
||||||
:align: center
|
: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
|
HTTPie is written in Python, and under the hood it uses the excellent
|
||||||
`Requests`_ and `Pygments`_ libraries.
|
`Requests`_ and `Pygments`_ libraries.
|
||||||
|
|
||||||
|
|
||||||
**Table of Contents**
|
-----
|
||||||
|
|
||||||
|
|pypi| |unix_build| |windows_build| |coverage|
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
|
||||||
.. contents::
|
.. contents::
|
||||||
@ -62,11 +58,9 @@ Main Features
|
|||||||
Installation
|
Installation
|
||||||
============
|
============
|
||||||
|
|
||||||
|
--------------
|
||||||
|
Stable version
|
||||||
------------------------
|
--------------
|
||||||
Stable version |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/>`_:
|
||||||
|
|
||||||
@ -75,9 +69,16 @@ On **Mac OS X**, HTTPie can be installed via `Homebrew <http://brew.sh/>`_:
|
|||||||
$ brew install httpie
|
$ brew install httpie
|
||||||
|
|
||||||
|
|
||||||
Most **Linux** distributions provide a package that can be installed via
|
Most **Linux** distributions provide a package that can be installed using the
|
||||||
system package manager, e.g. ``yum install httpie`` or ``apt-get install httpie``.
|
the system package manager, e.g.:
|
||||||
Note that the package might include a slightly older version of HTTPie.
|
|
||||||
|
.. 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, …,
|
A **universal installation method** (that works on **Windows**, Mac OS X, Linux, …,
|
||||||
@ -86,24 +87,20 @@ and provides the latest version) is to use `pip`_:
|
|||||||
|
|
||||||
.. code-block:: bash
|
.. 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
|
$ 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
|
Development version
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
============= =============
|
|
||||||
Mac/Linux Windows
|
|
||||||
|unix| |windows|
|
|
||||||
============= =============
|
|
||||||
|
|
||||||
|
|
||||||
The **latest development version** can be installed directly from GitHub:
|
The **latest development version** can be installed directly from GitHub:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
@ -362,7 +359,7 @@ object by default. HTTPie also automatically sets the following headers,
|
|||||||
both of which can be overwritten:
|
both of which can be overwritten:
|
||||||
|
|
||||||
================ =======================================
|
================ =======================================
|
||||||
``Content-Type`` ``application/json; charset=utf-8``
|
``Content-Type`` ``application/json``
|
||||||
``Accept`` ``application/json``
|
``Accept`` ``application/json``
|
||||||
================ =======================================
|
================ =======================================
|
||||||
|
|
||||||
@ -381,8 +378,8 @@ Simple example:
|
|||||||
|
|
||||||
PUT / HTTP/1.1
|
PUT / HTTP/1.1
|
||||||
Accept: application/json
|
Accept: application/json
|
||||||
Accept-Encoding: identity, deflate, compress, gzip
|
Accept-Encoding: gzip, deflate
|
||||||
Content-Type: application/json; charset=utf-8
|
Content-Type: application/json
|
||||||
Host: example.org
|
Host: example.org
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -408,7 +405,7 @@ fields using ``=@`` and ``:=@``:
|
|||||||
|
|
||||||
PUT /person/1 HTTP/1.1
|
PUT /person/1 HTTP/1.1
|
||||||
Accept: application/json
|
Accept: application/json
|
||||||
Content-Type: application/json; charset=utf-8
|
Content-Type: application/json
|
||||||
Host: api.example.com
|
Host: api.example.com
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -504,7 +501,7 @@ To set custom headers you can use the ``Header:Value`` notation:
|
|||||||
|
|
||||||
GET / HTTP/1.1
|
GET / HTTP/1.1
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Accept-Encoding: identity, deflate, compress, gzip
|
Accept-Encoding: gzip, deflate
|
||||||
Cookie: valued-visitor=yes;foo=bar
|
Cookie: valued-visitor=yes;foo=bar
|
||||||
Host: example.org
|
Host: example.org
|
||||||
Referer: http://httpie.org/
|
Referer: http://httpie.org/
|
||||||
@ -518,7 +515,7 @@ There are a couple of default headers that HTTPie sets:
|
|||||||
|
|
||||||
GET / HTTP/1.1
|
GET / HTTP/1.1
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Accept-Encoding: identity, deflate, compress, gzip
|
Accept-Encoding: gzip, deflate
|
||||||
User-Agent: HTTPie/<version>
|
User-Agent: HTTPie/<version>
|
||||||
Host: <taken-from-URL>
|
Host: <taken-from-URL>
|
||||||
|
|
||||||
@ -595,6 +592,7 @@ Auth Plugins
|
|||||||
* `httpie-ntlm <https://github.com/jakubroztocil/httpie-ntlm>`_: NTLM (NT LAN Manager)
|
* `httpie-ntlm <https://github.com/jakubroztocil/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
|
||||||
|
|
||||||
|
|
||||||
=======
|
=======
|
||||||
@ -725,8 +723,8 @@ documentation examples:
|
|||||||
$ http --verbose PUT httpbin.org/put hello=world
|
$ http --verbose PUT httpbin.org/put hello=world
|
||||||
PUT /put HTTP/1.1
|
PUT /put HTTP/1.1
|
||||||
Accept: application/json
|
Accept: application/json
|
||||||
Accept-Encoding: identity, deflate, compress, gzip
|
Accept-Encoding: gzip, deflate
|
||||||
Content-Type: application/json; charset=utf-8
|
Content-Type: application/json
|
||||||
Host: httpbin.org
|
Host: httpbin.org
|
||||||
User-Agent: HTTPie/0.2.7dev
|
User-Agent: HTTPie/0.2.7dev
|
||||||
|
|
||||||
@ -1276,14 +1274,17 @@ and usage from scripts, where HTTPie serves as a generic HTTP client.
|
|||||||
As HTTPie is still under heavy development, the existing command line
|
As HTTPie is still under heavy development, the existing command line
|
||||||
syntax and some of the ``--OPTIONS`` may change slightly before
|
syntax and some of the ``--OPTIONS`` may change slightly before
|
||||||
HTTPie reaches its final version ``1.0``. All changes are recorded in the
|
HTTPie reaches its final version ``1.0``. All changes are recorded in the
|
||||||
`changelog`_.
|
`change log`_.
|
||||||
|
|
||||||
|
|
||||||
==========
|
|
||||||
Contribute
|
|
||||||
==========
|
|
||||||
|
|
||||||
Please see `CONTRIBUTING`_.
|
=======
|
||||||
|
Authors
|
||||||
|
=======
|
||||||
|
|
||||||
|
|
||||||
|
`Jakub Roztocil`_ (`@jakubroztocil`_) created HTTPie and `these fine people`_
|
||||||
|
have contributed.
|
||||||
|
|
||||||
|
|
||||||
====
|
====
|
||||||
@ -1292,146 +1293,28 @@ Logo
|
|||||||
|
|
||||||
Please see `claudiatd/httpie-artwork`_
|
Please see `claudiatd/httpie-artwork`_
|
||||||
|
|
||||||
=======
|
|
||||||
Authors
|
|
||||||
=======
|
|
||||||
|
|
||||||
`Jakub Roztocil`_ (`@jakubroztocil`_) created HTTPie and `these fine people`_
|
==========
|
||||||
have contributed.
|
Contribute
|
||||||
|
==========
|
||||||
|
|
||||||
|
Please see `CONTRIBUTING <https://github.com/jakubroztocil/httpie/blob/master/CONTRIBUTING.rst>`_.
|
||||||
|
|
||||||
|
|
||||||
|
==========
|
||||||
|
Change Log
|
||||||
|
==========
|
||||||
|
|
||||||
|
Please see `CHANGELOG <https://github.com/jakubroztocil/httpie/blob/master/CHANGELOG.rst>`_.
|
||||||
|
|
||||||
|
|
||||||
=======
|
=======
|
||||||
Licence
|
Licence
|
||||||
=======
|
=======
|
||||||
|
|
||||||
Please see `LICENSE`_.
|
Please see `LICENSE <https://github.com/jakubroztocil/httpie/blob/master/LICENSE>`_.
|
||||||
|
|
||||||
|
|
||||||
=========
|
|
||||||
Changelog
|
|
||||||
=========
|
|
||||||
|
|
||||||
*You can click a version name to see a diff with the previous one.*
|
|
||||||
|
|
||||||
|
|
||||||
* `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` suppor.
|
|
||||||
* 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
|
.. _Requests: http://python-requests.org
|
||||||
.. _Pygments: http://pygments.org/
|
.. _Pygments: http://pygments.org/
|
||||||
@ -1441,35 +1324,20 @@ Changelog
|
|||||||
.. _Jakub Roztocil: http://subtleapps.com
|
.. _Jakub Roztocil: http://subtleapps.com
|
||||||
.. _@jakubroztocil: https://twitter.com/jakubroztocil
|
.. _@jakubroztocil: https://twitter.com/jakubroztocil
|
||||||
.. _claudiatd/httpie-artwork: https://github.com/claudiatd/httpie-artwork
|
.. _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.9.0...master
|
|
||||||
.. _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
|
.. |pypi| image:: https://img.shields.io/pypi/v/httpie.svg?style=flat-square&label=latest%20version
|
||||||
:target: http://badge.fury.io/py/httpie
|
:target: https://pypi.python.org/pypi/httpie
|
||||||
|
:alt: Latest version released on PyPi
|
||||||
|
|
||||||
.. |unix| image:: https://api.travis-ci.org/jakubroztocil/httpie.svg
|
.. |coverage| image:: https://img.shields.io/coveralls/jakubroztocil/httpie/master.svg?style=flat-square
|
||||||
|
:target: https://coveralls.io/r/jakubroztocil/httpie?branch=master
|
||||||
|
:alt: Test coverage
|
||||||
|
|
||||||
|
.. |unix_build| image:: https://img.shields.io/travis/jakubroztocil/httpie/master.svg?style=flat-square&label=unix%20build
|
||||||
:target: http://travis-ci.org/jakubroztocil/httpie
|
:target: http://travis-ci.org/jakubroztocil/httpie
|
||||||
:alt: Build Status of the master branch on Mac/Linux
|
:alt: Build status of the master branch on Mac/Linux
|
||||||
|
|
||||||
.. |windows| image:: https://ci.appveyor.com/api/projects/status/f7b5dogxuseq8srw
|
.. |windows_build| image:: https://img.shields.io/appveyor/ci/jakubroztocil/httpie.svg?style=flat-square&label=windows%20build
|
||||||
:target: https://ci.appveyor.com/project/jakubroztocil/httpie
|
:target: https://ci.appveyor.com/project/jakubroztocil/httpie
|
||||||
:alt: Build Status of the master branch on Windows
|
:alt: Build status of the master branch on Windows
|
||||||
|
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'
|
__author__ = 'Jakub Roztocil'
|
||||||
__version__ = '0.9.0'
|
__version__ = '0.9.2'
|
||||||
__licence__ = 'BSD'
|
__licence__ = 'BSD'
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import sys
|
|||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
from requests.packages import urllib3
|
||||||
|
|
||||||
from httpie import sessions
|
from httpie import sessions
|
||||||
from httpie import __version__
|
from httpie import __version__
|
||||||
@ -10,21 +11,37 @@ 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
|
||||||
|
urllib3.disable_warnings()
|
||||||
|
|
||||||
|
|
||||||
FORM = 'application/x-www-form-urlencoded; charset=utf-8'
|
FORM = 'application/x-www-form-urlencoded; charset=utf-8'
|
||||||
JSON = 'application/json; charset=utf-8'
|
JSON = 'application/json'
|
||||||
DEFAULT_UA = 'HTTPie/%s' % __version__
|
DEFAULT_UA = 'HTTPie/%s' % __version__
|
||||||
|
|
||||||
|
|
||||||
|
def get_requests_session():
|
||||||
|
requests_session = requests.Session()
|
||||||
|
for cls in plugin_manager.get_trasnsport_plugins():
|
||||||
|
transport_plugin = cls()
|
||||||
|
requests_session.mount(prefix=transport_plugin.prefix,
|
||||||
|
adapter=transport_plugin.get_adapter())
|
||||||
|
return requests_session
|
||||||
|
|
||||||
|
|
||||||
def get_response(args, config_dir):
|
def get_response(args, config_dir):
|
||||||
"""Send the request and return a `request.Response`."""
|
"""Send the request and return a `request.Response`."""
|
||||||
|
|
||||||
|
requests_session = get_requests_session()
|
||||||
|
|
||||||
if not args.session and not args.session_read_only:
|
if not args.session and not args.session_read_only:
|
||||||
requests_kwargs = get_requests_kwargs(args)
|
kwargs = get_requests_kwargs(args)
|
||||||
if args.debug:
|
if args.debug:
|
||||||
dump_request(requests_kwargs)
|
dump_request(kwargs)
|
||||||
response = requests.request(**requests_kwargs)
|
response = requests_session.request(**kwargs)
|
||||||
else:
|
else:
|
||||||
response = sessions.get_response(
|
response = sessions.get_response(
|
||||||
|
requests_session=requests_session,
|
||||||
args=args,
|
args=args,
|
||||||
config_dir=config_dir,
|
config_dir=config_dir,
|
||||||
session_name=args.session or args.session_read_only,
|
session_name=args.session or args.session_read_only,
|
||||||
|
@ -2,27 +2,44 @@
|
|||||||
Python 2.6, 2.7, and 3.x compatibility.
|
Python 2.6, 2.7, and 3.x compatibility.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# Borrow these from requests:
|
import sys
|
||||||
# noinspection PyUnresolvedReferences
|
|
||||||
from requests.compat import is_windows, bytes, str, is_py3, is_py26
|
|
||||||
|
|
||||||
try:
|
|
||||||
|
# Taken from `requests.compat`
|
||||||
|
_ver = sys.version_info
|
||||||
|
is_py2 = (_ver[0] == 2)
|
||||||
|
is_py26 = (is_py2 and _ver[1] == 6)
|
||||||
|
is_py27 = (is_py2 and _ver[1] == 7)
|
||||||
|
is_py3 = (_ver[0] == 3)
|
||||||
|
is_pypy = ('pypy' in _ver)
|
||||||
|
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
|
# noinspection PyUnresolvedReferences,PyCompatibility
|
||||||
from urllib.parse import urlsplit
|
from urllib.parse import urlsplit
|
||||||
except ImportError:
|
except ImportError: # pragma: no cover
|
||||||
# noinspection PyUnresolvedReferences,PyCompatibility
|
# noinspection PyUnresolvedReferences,PyCompatibility
|
||||||
from urlparse import urlsplit
|
from urlparse import urlsplit
|
||||||
|
|
||||||
try:
|
try: # pragma: no cover
|
||||||
# noinspection PyCompatibility
|
# noinspection PyCompatibility
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
except ImportError:
|
except ImportError: # pragma: no cover
|
||||||
# noinspection PyCompatibility
|
# noinspection PyCompatibility
|
||||||
from urllib2 import urlopen
|
from urllib2 import urlopen
|
||||||
|
|
||||||
try:
|
try: # pragma: no cover
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
except ImportError:
|
except ImportError: # pragma: no cover
|
||||||
# Python 2.6 OrderedDict class, needed for headers, parameters, etc .###
|
# Python 2.6 OrderedDict class, needed for headers, parameters, etc .###
|
||||||
# <https://pypi.python.org/pypi/ordereddict/1.1>
|
# <https://pypi.python.org/pypi/ordereddict/1.1>
|
||||||
# noinspection PyCompatibility
|
# noinspection PyCompatibility
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from requests.compat import is_windows
|
from httpie.compat import is_windows
|
||||||
|
|
||||||
from httpie.config import DEFAULT_CONFIG_DIR, Config
|
from httpie.config import DEFAULT_CONFIG_DIR, Config
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import errno
|
|||||||
import mimetypes
|
import mimetypes
|
||||||
import getpass
|
import getpass
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from collections import namedtuple
|
from collections import namedtuple, Iterable
|
||||||
# noinspection PyCompatibility
|
# noinspection PyCompatibility
|
||||||
from argparse import ArgumentParser, ArgumentTypeError, ArgumentError
|
from argparse import ArgumentParser, ArgumentTypeError, ArgumentError
|
||||||
|
|
||||||
@ -16,11 +16,15 @@ from argparse import ArgumentParser, ArgumentTypeError, ArgumentError
|
|||||||
# https://github.com/jakubroztocil/httpie/issues/130
|
# https://github.com/jakubroztocil/httpie/issues/130
|
||||||
from requests.structures import CaseInsensitiveDict
|
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.sessions import VALID_SESSION_NAME_PATTERN
|
||||||
from httpie.utils import load_json_preserve_order
|
from httpie.utils import load_json_preserve_order
|
||||||
|
|
||||||
|
|
||||||
|
# ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
|
||||||
|
# <http://tools.ietf.org/html/rfc3986#section-3.1>
|
||||||
|
URL_SCHEME_RE = re.compile(r'^[a-z][a-z0-9.+-]*://', re.IGNORECASE)
|
||||||
|
|
||||||
HTTP_POST = 'POST'
|
HTTP_POST = 'POST'
|
||||||
HTTP_GET = 'GET'
|
HTTP_GET = 'GET'
|
||||||
HTTP = 'http://'
|
HTTP = 'http://'
|
||||||
@ -132,7 +136,7 @@ class Parser(ArgumentParser):
|
|||||||
self._parse_items()
|
self._parse_items()
|
||||||
if not self.args.ignore_stdin and not env.stdin_isatty:
|
if not self.args.ignore_stdin and not env.stdin_isatty:
|
||||||
self._body_from_file(self.env.stdin)
|
self._body_from_file(self.env.stdin)
|
||||||
if not (self.args.url.startswith((HTTP, HTTPS))):
|
if not URL_SCHEME_RE.match(self.args.url):
|
||||||
scheme = HTTP
|
scheme = HTTP
|
||||||
|
|
||||||
# See if we're using curl style shorthand for localhost (:3000/foo)
|
# See if we're using curl style shorthand for localhost (:3000/foo)
|
||||||
@ -557,6 +561,17 @@ class AuthCredentialsArgType(KeyValueArgType):
|
|||||||
class RequestItemsDict(OrderedDict):
|
class RequestItemsDict(OrderedDict):
|
||||||
"""Multi-value dict for URL parameters and form data."""
|
"""Multi-value dict for URL parameters and form data."""
|
||||||
|
|
||||||
|
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
|
#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
|
||||||
|
@ -52,7 +52,14 @@ class HTTPResponse(HTTPMessage):
|
|||||||
@property
|
@property
|
||||||
def headers(self):
|
def headers(self):
|
||||||
original = self._orig.raw._original_response
|
original = self._orig.raw._original_response
|
||||||
version = {9: '0.9', 10: '1.0', 11: '1.1'}[original.version]
|
|
||||||
|
version = {
|
||||||
|
9: '0.9',
|
||||||
|
10: '1.0',
|
||||||
|
11: '1.1',
|
||||||
|
20: '2',
|
||||||
|
}[original.version]
|
||||||
|
|
||||||
status_line = 'HTTP/{version} {status} {reason}'.format(
|
status_line = 'HTTP/{version} {status} {reason}'.format(
|
||||||
version=version,
|
version=version,
|
||||||
status=original.status,
|
status=original.status,
|
||||||
|
@ -7,7 +7,6 @@ from pygments.formatters.terminal import TerminalFormatter
|
|||||||
from pygments.formatters.terminal256 import Terminal256Formatter
|
from pygments.formatters.terminal256 import Terminal256Formatter
|
||||||
from pygments.util import ClassNotFound
|
from pygments.util import ClassNotFound
|
||||||
|
|
||||||
from httpie.compat import is_windows
|
|
||||||
from httpie.plugins import FormatterPlugin
|
from httpie.plugins import FormatterPlugin
|
||||||
|
|
||||||
|
|
||||||
@ -15,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' if not is_windows else 'fruity'
|
DEFAULT_STYLE = 'solarized'
|
||||||
|
|
||||||
|
|
||||||
class ColorFormatter(FormatterPlugin):
|
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):
|
class Solarized256Style(pygments.style.Style):
|
||||||
"""
|
"""
|
||||||
solarized256
|
solarized256
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
from httpie.plugins.base import AuthPlugin, FormatterPlugin, ConverterPlugin
|
"""
|
||||||
|
WARNING: The plugin API is still work in progress and will
|
||||||
|
probably be completely reworked by v1.0.0.
|
||||||
|
|
||||||
|
"""
|
||||||
|
from httpie.plugins.base import (
|
||||||
|
AuthPlugin, FormatterPlugin,
|
||||||
|
ConverterPlugin, TransportPlugin
|
||||||
|
)
|
||||||
from httpie.plugins.manager import PluginManager
|
from httpie.plugins.manager import PluginManager
|
||||||
from httpie.plugins.builtin import BasicAuthPlugin, DigestAuthPlugin
|
from httpie.plugins.builtin import BasicAuthPlugin, DigestAuthPlugin
|
||||||
from httpie.output.formatters.headers import HeadersFormatter
|
from httpie.output.formatters.headers import HeadersFormatter
|
||||||
|
@ -15,7 +15,7 @@ class AuthPlugin(BasePlugin):
|
|||||||
"""
|
"""
|
||||||
Base auth plugin class.
|
Base auth plugin class.
|
||||||
|
|
||||||
See <https://github.com/jkbr/httpie-ntlm> for an example auth plugin.
|
See <https://github.com/jakubroztocil/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
|
||||||
@ -30,6 +30,25 @@ class AuthPlugin(BasePlugin):
|
|||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
|
||||||
|
class TransportPlugin(BasePlugin):
|
||||||
|
"""
|
||||||
|
|
||||||
|
http://docs.python-requests.org/en/latest/user/advanced/#transport-adapters
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# The URL prefix the adapter should be mount to.
|
||||||
|
prefix = None
|
||||||
|
|
||||||
|
def get_adapter(self):
|
||||||
|
"""
|
||||||
|
Return a ``requests.adapters.BaseAdapter`` subclass instance to be
|
||||||
|
mounted to ``self.prefix``.
|
||||||
|
|
||||||
|
"""
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
|
||||||
class ConverterPlugin(object):
|
class ConverterPlugin(object):
|
||||||
|
|
||||||
def __init__(self, mime):
|
def __init__(self, mime):
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
from pkg_resources import iter_entry_points
|
from pkg_resources import iter_entry_points
|
||||||
from httpie.plugins import AuthPlugin, FormatterPlugin, ConverterPlugin
|
from httpie.plugins import AuthPlugin, FormatterPlugin, ConverterPlugin
|
||||||
|
from httpie.plugins.base import TransportPlugin
|
||||||
|
|
||||||
|
|
||||||
ENTRY_POINT_NAMES = [
|
ENTRY_POINT_NAMES = [
|
||||||
'httpie.plugins.auth.v1',
|
'httpie.plugins.auth.v1',
|
||||||
'httpie.plugins.formatter.v1',
|
'httpie.plugins.formatter.v1',
|
||||||
'httpie.plugins.converter.v1',
|
'httpie.plugins.converter.v1',
|
||||||
|
'httpie.plugins.transport.v1',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -56,3 +58,8 @@ class PluginManager(object):
|
|||||||
def get_converters(self):
|
def get_converters(self):
|
||||||
return [plugin for plugin in self
|
return [plugin for plugin in self
|
||||||
if issubclass(plugin, ConverterPlugin)]
|
if issubclass(plugin, ConverterPlugin)]
|
||||||
|
|
||||||
|
# Adapters
|
||||||
|
def get_trasnsport_plugins(self):
|
||||||
|
return [plugin for plugin in self
|
||||||
|
if issubclass(plugin, TransportPlugin)]
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import requests
|
|
||||||
from requests.cookies import RequestsCookieJar, create_cookie
|
from requests.cookies import RequestsCookieJar, create_cookie
|
||||||
|
|
||||||
from httpie.compat import urlsplit
|
from httpie.compat import urlsplit
|
||||||
@ -21,7 +20,8 @@ VALID_SESSION_NAME_PATTERN = re.compile('^[a-zA-Z0-9_.-]+$')
|
|||||||
SESSION_IGNORED_HEADER_PREFIXES = ['Content-', 'If-']
|
SESSION_IGNORED_HEADER_PREFIXES = ['Content-', 'If-']
|
||||||
|
|
||||||
|
|
||||||
def get_response(session_name, config_dir, args, read_only=False):
|
def get_response(requests_session, session_name,
|
||||||
|
config_dir, args, read_only=False):
|
||||||
"""Like `client.get_response`, but applies permanent
|
"""Like `client.get_response`, but applies permanent
|
||||||
aspects of the session to the request.
|
aspects of the session to the request.
|
||||||
|
|
||||||
@ -32,7 +32,9 @@ def get_response(session_name, config_dir, args, read_only=False):
|
|||||||
else:
|
else:
|
||||||
hostname = (args.headers.get('Host', None)
|
hostname = (args.headers.get('Host', None)
|
||||||
or urlsplit(args.url).netloc.split('@')[-1])
|
or urlsplit(args.url).netloc.split('@')[-1])
|
||||||
assert re.match('^[a-zA-Z0-9_.:-]+$', hostname)
|
if not hostname:
|
||||||
|
# HACK/FIXME: httpie-unixsocket's URLs have no hostname.
|
||||||
|
hostname = 'localhost'
|
||||||
|
|
||||||
# host:port => host_port
|
# host:port => host_port
|
||||||
hostname = hostname.replace(':', '_')
|
hostname = hostname.replace(':', '_')
|
||||||
@ -44,10 +46,10 @@ def get_response(session_name, config_dir, args, read_only=False):
|
|||||||
session = Session(path)
|
session = Session(path)
|
||||||
session.load()
|
session.load()
|
||||||
|
|
||||||
requests_kwargs = get_requests_kwargs(args, base_headers=session.headers)
|
kwargs = get_requests_kwargs(args, base_headers=session.headers)
|
||||||
if args.debug:
|
if args.debug:
|
||||||
dump_request(requests_kwargs)
|
dump_request(kwargs)
|
||||||
session.update_headers(requests_kwargs['headers'])
|
session.update_headers(kwargs['headers'])
|
||||||
|
|
||||||
if args.auth:
|
if args.auth:
|
||||||
session.auth = {
|
session.auth = {
|
||||||
@ -56,13 +58,12 @@ def get_response(session_name, config_dir, args, read_only=False):
|
|||||||
'password': args.auth.value,
|
'password': args.auth.value,
|
||||||
}
|
}
|
||||||
elif session.auth:
|
elif session.auth:
|
||||||
requests_kwargs['auth'] = session.auth
|
kwargs['auth'] = session.auth
|
||||||
|
|
||||||
requests_session = requests.Session()
|
|
||||||
requests_session.cookies = session.cookies
|
requests_session.cookies = session.cookies
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests_session.request(**requests_kwargs)
|
response = requests_session.request(**kwargs)
|
||||||
except Exception:
|
except Exception:
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
import json
|
import json
|
||||||
# noinspection PyCompatibility
|
# noinspection PyCompatibility
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from requests.exceptions import InvalidSchema
|
||||||
|
|
||||||
from httpie import input
|
from httpie import input
|
||||||
from httpie.input import KeyValue, KeyValueArgType, DataDict
|
from httpie.input import KeyValue, KeyValueArgType, DataDict
|
||||||
@ -321,3 +321,12 @@ class TestIgnoreStdin:
|
|||||||
error_exit_ok=True)
|
error_exit_ok=True)
|
||||||
assert r.exit_status == ExitStatus.ERROR
|
assert r.exit_status == ExitStatus.ERROR
|
||||||
assert 'because --ignore-stdin' in r.stderr
|
assert 'because --ignore-stdin' in r.stderr
|
||||||
|
|
||||||
|
|
||||||
|
class TestSchemes:
|
||||||
|
|
||||||
|
def test_custom_scheme(self):
|
||||||
|
# InvalidSchema is expected because HTTPie
|
||||||
|
# shouldn't touch a formally valid scheme.
|
||||||
|
with pytest.raises(InvalidSchema):
|
||||||
|
http('foo+bar-BAZ.123://bah')
|
||||||
|
@ -59,14 +59,14 @@ class TestAutoContentTypeAndAcceptHeaders:
|
|||||||
r = http('POST', httpbin.url + '/post', 'a=b')
|
r = http('POST', httpbin.url + '/post', 'a=b')
|
||||||
assert HTTP_OK in r
|
assert HTTP_OK in r
|
||||||
assert '"Accept": "application/json"' 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):
|
def test_GET_with_data_auto_JSON_headers(self, httpbin):
|
||||||
# JSON headers should automatically be set also for GET with data.
|
# JSON headers should automatically be set also for GET with data.
|
||||||
r = http('POST', httpbin.url + '/post', 'a=b')
|
r = http('POST', httpbin.url + '/post', 'a=b')
|
||||||
assert HTTP_OK in r
|
assert HTTP_OK in r
|
||||||
assert '"Accept": "application/json"' in r, 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):
|
def test_POST_explicit_JSON_auto_JSON_accept(self, httpbin):
|
||||||
r = http('--json', 'POST', httpbin.url + '/post')
|
r = http('--json', 'POST', httpbin.url + '/post')
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from utils import TestEnvironment, http, HTTP_OK, COLOR, CRLF
|
||||||
from httpie import ExitStatus
|
from httpie import ExitStatus
|
||||||
from httpie.output.formatters.colors import get_lexer
|
from httpie.output.formatters.colors import get_lexer
|
||||||
from utils import TestEnvironment, http, HTTP_OK, COLOR, CRLF
|
|
||||||
|
|
||||||
|
|
||||||
class TestVerboseFlag:
|
class TestVerboseFlag:
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from httpie.plugins.builtin import HTTPBasicAuth
|
from httpie.plugins.builtin import HTTPBasicAuth
|
||||||
from utils import TestEnvironment, mk_config_dir, http, HTTP_OK, \
|
from utils import TestEnvironment, mk_config_dir, http, HTTP_OK, \
|
||||||
@ -132,6 +135,10 @@ class TestSession(SessionTestBase):
|
|||||||
assert HTTP_OK in r2
|
assert HTTP_OK in r2
|
||||||
assert r2.json['headers']['Foo'] == 'Bar'
|
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/jakubroztocil/httpie/issues/282")
|
||||||
def test_session_unicode(self, httpbin):
|
def test_session_unicode(self, httpbin):
|
||||||
self.start_session(httpbin)
|
self.start_session(httpbin)
|
||||||
|
|
||||||
|
2
tox.ini
2
tox.ini
@ -12,7 +12,7 @@ envlist = py26, py27, py34, pypy
|
|||||||
[testenv]
|
[testenv]
|
||||||
deps =
|
deps =
|
||||||
pytest
|
pytest
|
||||||
pytest-httpbin
|
pytest-httpbin>=0.0.6
|
||||||
|
|
||||||
commands =
|
commands =
|
||||||
py.test --verbose --doctest-modules --basetemp={envtmpdir} {posargs:./tests ./httpie}
|
py.test --verbose --doctest-modules --basetemp={envtmpdir} {posargs:./tests ./httpie}
|
||||||
|
Reference in New Issue
Block a user