Compare commits

...

108 Commits
0.9.0 ... 0.9.3

Author SHA1 Message Date
4722076335 v0.9.3 2016-01-01 19:27:07 -03:00
f14a0ad37d Fix pytest configuration 2016-01-01 19:11:22 -03:00
4cadc1d4c0 Update pytest configuration
* Move it from tox.ini to pytest.ini
* Ignore tests/fixtures
2016-01-01 19:08:27 -03:00
c3e5456aba Update setuptools on Appveyor 2016-01-01 19:01:39 -03:00
33489c9a91 Update pip on Appveyor 2016-01-01 18:51:17 -03:00
4e2b6b0ccc Update get-pip.py URL 2016-01-01 18:46:01 -03:00
b034c8703a PEP8 2016-01-01 18:41:58 -03:00
ab3d2656af Undo 'Fix "mock requires setuptools>=17.1. Aborting installation" on Win+Py3' 2016-01-01 18:38:06 -03:00
c42bd0051a Merge pull request #396 from pathcl/master
PEP8 errors
2016-01-01 18:37:49 -03:00
288cb4fdeb Fix "mock requires setuptools>=17.1. Aborting installation" on Win+Py3 2016-01-01 18:27:43 -03:00
8771d759fe Merge pull request #382 from konopski/master
[#381] Fixed --auth prompt on Windows
2016-01-01 18:18:23 -03:00
2cdca36960 Merge pull request #386 from honorabrutroll/dev
Fixed --pretty on Windows (closes #372)
2016-01-01 18:15:50 -03:00
8dc4f04fda Merge pull request #419 from hangtwenty/master
Fail gracefully if disable_warnings not available
2016-01-01 17:58:23 -03:00
dadc0cd27c Merge pull request #417 from yansal/patch-1
Fix typo in CONTRIBUTING.rst
2016-01-01 17:57:48 -03:00
59fd42244a Merge pull request #421 from Altreus/patch-1
Aitch already has an official spelling - use it
2016-01-01 17:56:52 -03:00
6afe9c32c4 Merge pull request #424 from t-mart/master
Remove duplicate setup.py test option
2015-12-28 13:56:14 -03:00
cc0ba03290 Remove duplicate setup.py test option 2015-12-28 10:38:07 -06:00
fad84a962e Aitch already has an official spelling - use it
http://www.oxforddictionaries.com/definition/english/aitch
2015-12-15 14:39:26 +00:00
4f755a8bde Fail gracefully if disable_warnings not available
Addresses #418. Rationale explained there.
2015-12-02 11:50:48 -06:00
21ee981fc6 Fix typo in CONTRIBUTING.rst 2015-11-27 15:02:23 +01:00
45df860124 PEP8 errors 2015-10-22 14:32:16 -03:00
277da1ff93 str conversion 2015-10-21 21:57:06 +02:00
1ded5c2a97 Merge pull request #387 from yurimalheiros/patch-1
Update README.rst
2015-10-07 19:41:24 +02:00
69bd72ce95 Update README.rst
Fix a simple typo
2015-10-07 14:17:53 -03:00
8bf6db471b Fixed AUTHORS.rst 2015-10-04 17:16:41 -05:00
b1cc069fce Add Edward Yang to AUTHORS.rst 2015-10-04 17:06:54 -05:00
ed484c278b Change pretty option processor to only raise error when using output file 2015-10-04 17:06:00 -05:00
aec0f04f5d [#381] --auth fails on windows 2015-09-21 16:30:46 +02:00
8eb460a6f3 Disable OSX travis builds for now
OSX/Python support isn't probably not ready on Travis' side yet. 

https://travis-ci.org/jkbrzt/httpie/jobs/78219565#L27

// cc @msabramo — any idea?
2015-09-11 16:24:42 +02:00
5fe5958b06 Update README.rst 2015-09-01 15:11:36 +02:00
0e1c17daa1 Merge pull request #375 from hoatle/jwt-auth-plugin-reference
mention httpie-jwt-auth plugin on README
2015-09-01 15:10:41 +02:00
307517e7ef Merge pull request #377 from mblayman/fix-trasnsport
Fix trasnsport typo in plugin manager.
2015-08-31 06:20:01 +02:00
d60a04da2d Add Matt Layman to AUTHORS. 2015-08-30 21:41:14 -04:00
9ea89ffefe Fix typo in method name of plugin manager. 2015-08-30 21:37:47 -04:00
bebeb2100d mention httpie-jwt-auth plugin on README 2015-08-24 01:58:00 +07:00
2b51cb6687 Updated links II. 2015-07-03 18:55:45 +02:00
fa4bd033ef Updated links. 2015-07-03 03:40:38 +02:00
f8c1104429 Fixed link to httpie-edgegrid 2015-06-30 11:51:40 +02:00
be9d9281b7 Added a link to the httpie-edgegrid plugin. 2015-06-30 11:50:11 +02:00
ced0838598 Converted tabs to spaces. 2015-06-26 16:39:23 +02:00
d8b819b03f Merge pull request #337 from joaodelgado/json-serialization
Only serialize json if data is a dict instance
2015-04-24 15:07:16 +02:00
6fd0f23f39 Only serialize json if data is a dict instance 2015-04-11 02:11:22 +01:00
483546d781 Added mock to tests_require 2015-03-25 22:52:49 +01:00
daf3573908 Update CHANGELOG.rst 2015-03-25 22:37:48 +01:00
62407f781f Update CHANGELOG.rst 2015-03-25 22:35:36 +01:00
cbbaac13ea Merge pull request #300 from msabramo/print_info_about_request_on_error
Print info about request on error
2015-03-25 22:21:18 +01:00
6aad79d71c Merge pull request #319 from fay-jai/license
Update license with up-to-date year
2015-03-25 22:18:42 +01:00
c1f26347fc Merge pull request #330 from mihirvj/bash-completion
Bash auto completion
2015-03-25 22:08:13 +01:00
29a0147dd5 See #326
Adds bash completion to http command line interface.

Installing the script:
You can copy it to /etc/bash_completion.d/ (or something else on your
machine) and source it using following command

	$ source /etc/profile

Now whenever you encounter a "-*" on your CLI, it presents you with the
options specified.

Couple of things that are still under work:
1) Adding this bash script to setup, so that user won't need manual
installation
2) Adding more options for HTTP (GET, PUT and so on) and other
options
2015-03-24 22:26:10 -04:00
ab0d1fd8d0 Added .editorconfig. 2015-03-13 17:17:17 +01:00
35a3dd2855 Merge pull request #321 from ifdattic/patch-1
Fix typos, improve readability
2015-03-10 09:37:40 +01:00
ece85c0f0c Fix typos, improve readability 2015-03-10 10:05:13 +02:00
798cd4f0ec Update license with up-to-date year 2015-03-08 11:29:33 -07:00
1a43c0e5f7 Fixed --debug output 2015-02-28 17:02:05 +01:00
fdabbc6048 Typo 2015-02-24 16:50:02 +01:00
5f3de558cb README 2015-02-24 16:41:34 +01:00
fdae686e12 Clean up compat and fix is_pypy. 2015-02-24 08:18:03 +01:00
1c181a5d25 1.0.0-dev 2015-02-24 07:52:34 +01:00
a228399801 0.9.2 2015-02-24 07:50:15 +01:00
bada3b45f1 Use absolute links to LICENCE, etc. 2015-02-24 07:50:15 +01:00
e4bc363f9e Don't depend on requests.compat
#314
2015-02-24 07:50:15 +01:00
24957e3b61 Update requirements-dev.txt
dd7f1c4
2015-02-16 21:55:40 +01:00
fb437591da Include AUTHORS.rst in dist; metadata cleanup 2015-02-16 21:42:09 +01:00
b7fc89acdc README fixes 2015-02-16 21:29:40 +01:00
2e88aa53cf Extracted changes from README into a proper CHANGELOG file
Inspired by keepachangelog.com
2015-02-16 21:16:39 +01:00
9e62151bec Merge pull request #312 from msabramo/patch-5
tox.ini: Use pytest-httpbin>=0.0.6
2015-02-16 20:27:35 +01:00
ecc59591f1 Disable urllib3's "Unverified HTTPS request is being made" warnings 2015-02-16 19:36:02 +01:00
f855de16c2 Increase test coverage for error handling 2015-02-15 23:22:52 -08:00
7f8adad313 Print info about request on error
This can help in diagnosing certain issues. For example, if I were
trying to use a "http+unix" URL but I don't have #299, then I'll get the
following:

    [marca@marca-mac2 httpie]$ http http+unix://%2Ftmp%2Fprofilesvc.sock/status/pid

    http: error: ConnectionError: ('Connection aborted.', gaierror(8, 'nodename nor servname provided, or not known'))
    while doing GET request to URL: http://http+unix//%2Ftmp%2Fprofilesvc.sock/status/pid

Having the URL in the error message is super useful here so that I know an
extra `http://` is getting prepended and it's not doing what I expected.
2015-02-15 23:22:52 -08:00
51c19cfe10 test_ssl.py: Remove skip failures on PyPy
Revert 985f65e which skipped SSL tests that failed on PyPy because @kevin1024 fixed the problem in pytest-httpbin 0.0.6 (commit f38a312446)
2015-02-15 21:42:34 -08:00
dd7f1c4cce tox.ini: Use pytest-httpbin>=0.0.6
This hopefully fixes SSL timeout errors. 

Fixes #308
2015-02-15 20:33:57 -08:00
45784c7260 Fixed TOC 2015-02-15 12:57:57 +01:00
868baaba4e README 2015-02-15 12:53:57 +01:00
5760b780a0 README 2015-02-15 11:28:53 +01:00
2e5d14238f Tweak badge style 2015-02-15 00:54:49 +01:00
3b3eff01b7 Use shields.io badges 2015-02-15 00:51:58 +01:00
42f454eb6b README 2015-02-15 00:43:24 +01:00
40d95b650c README 2015-02-15 00:42:41 +01:00
bc0d17c04c Added a PyPy incompatibility workaround. 2015-02-15 00:36:55 +01:00
985f65ef52 Temporarily skip SSL tests on PyPy due to #308 2015-02-14 23:14:06 +01:00
dd0a4ab87a Default --style to "monokai"
419ca85
2015-02-14 22:51:31 +01:00
07aaefa232 Updated screenshot 2015-02-14 18:18:43 +01:00
419ca85e62 The default color --style is now "fruity"
It's experimental - please let me know should you dislike this change.

To make Solarized default again, add this to your ~/.config.json:

  "default_options": [
    "--style=solarized"
  ],
2015-02-14 18:18:04 +01:00
596fdc8c7e Update README examples with the new default Accept-Encoding value used by Requests. 2015-02-14 17:55:34 +01:00
6e7e2f2eea Changed the default JSON Content-Type to application/json. 2015-02-14 17:45:15 +01:00
748794257c Merge pull request #306 from msabramo/patch-4
.travis.yml: sudo false for Docker containers
2015-02-10 17:41:32 +01:00
55fa975ae5 .travis.yml: sudo false for Docker containers
Enables new Docker container infrastructure.
2015-02-10 07:41:38 -08:00
e6e94398ae Merge pull request #303 from msabramo/coveralls_only_one
.travis.yml: Only do coveralls on the latest Python version
2015-02-10 16:38:54 +01:00
fbd44640e6 .travis.yml: Only do coveralls on newest python
Testing theory that it has to do with different python version subjobs
completing in different orders and the last one wins.
2015-02-10 07:37:03 -08:00
43915b5fc0 Merge pull request #304 from msabramo/patch-2
compat.py: Add pragma no covers
2015-02-10 16:00:59 +01:00
f1e1299104 Merge pull request #305 from msabramo/patch-3
Conditionally skip test_session_unicode on Py3k
2015-02-10 16:00:24 +01:00
86ebb9b741 compat.py: Add pragma no covers
Cuz this is a lot of version-specific stuff and it can be confusing to have different coverage per version, especially with coveralls.
2015-02-10 06:54:59 -08:00
873102d5eb Mark test_session_unicode as xfail
There are known problems with unicode in headers.
See https://github.com/jakubroztocil/httpie/issues/282
2015-02-10 06:52:51 -08:00
337c05f95c README 2015-02-07 18:06:49 +01:00
a786f17997 1.0.0-dev 2015-02-07 17:04:33 +01:00
753a8d04e4 v0.9.1 2015-02-07 17:04:13 +01:00
3ff03524ff HTTP/2 has no minor versions.
https://github.com/jakubroztocil/httpie-http2/issues/1
2015-02-07 16:31:42 +01:00
a5a83c5b77 Prevent a circular import issue. 2015-02-07 16:29:17 +01:00
9682f955b5 Handle HTTP/2 responses
https://github.com/jakubroztocil/httpie-http2/issues/1#issuecomment-73301801
2015-02-06 21:13:57 +01:00
0d21ff022e Added a link to @pd's httpie-api-auth plugin 2015-02-06 20:06:50 +01:00
996e314482 Cleanup 2015-02-05 15:55:20 +01:00
687a6a734d Added support for transport adapter plugins
#276, #298
2015-02-05 15:25:00 +01:00
b125ce5eae Allow custom URL schemes
Closes #299

See also #276
2015-02-05 14:35:34 +01:00
92a4352f10 Added a coveralls badge. 2015-01-31 17:49:48 +01:00
c0f1fb61ac Merge pull request #297 from msabramo/patch-1
README.rst: suppor => support
2015-01-31 16:15:42 +01:00
17358be1ae README.rst: suppor => support 2015-01-31 07:01:54 -08:00
338d39c841 Fixed version link 2015-01-31 13:23:52 +01:00
530d6c5e27 1.0.0-dev 2015-01-31 13:22:17 +01:00
44 changed files with 680 additions and 329 deletions

17
.editorconfig Normal file
View 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

View File

@ -1,7 +1,11 @@
# https://travis-ci.org/jakubroztocil/httpie
# https://travis-ci.org/jkbrzt/httpie
sudo: false
os:
- linux
- osx
# - osx
env:
global:
- NEWEST_PYTHON=3.4
language: python
python:
- 2.6
@ -13,5 +17,4 @@ python:
script:
- make
after_success:
- pip install python-coveralls
- coveralls
- if [[ $TRAVIS_PYTHON_VERSION == $NEWEST_PYTHON ]]; then pip install python-coveralls && coveralls; fi

View File

@ -2,7 +2,7 @@
HTTPie authors
==============
* `Jakub Roztocil <https://github.com/jakubroztocil>`_
* `Jakub Roztocil <https://github.com/jkbrzt>`_
Patches and ideas
@ -32,3 +32,5 @@ Patches and ideas
* `Nathan LaFreniere <https://github.com/nlf>`_
* `Matthias Lehmann <https://github.com/matleh>`_
* `Dennis Brakhane <https://github.com/brakhane>`_
* `Matt Layman <https://github.com/mblayman>`_
* `Edward Yang <https://github.com/honorabrutroll>`_

260
CHANGELOG.rst Normal file
View File

@ -0,0 +1,260 @@
==========
Change Log
==========
This document records all notable changes to `HTTPie <http://httpie.org>`_.
This project adheres to `Semantic Versioning <http://semver.org/>`_.
`0.9.3`_ (2016-01-01)
-------------------------
* Changed the default color ``--style`` from ``solarized`` to ``monokai``
* Added basic Bash autocomplete support (need to be installed manually)
* Added request details to connection error messages
* Fixed ``'requests.packages.urllib3' has no attribute 'disable_warnings'``
errors that occurred in some installations
* Fixed colors and formatting on Windows
* Fixed ``--auth`` prompt on Windows
`0.9.2`_ (2015-02-24)
---------------------
* Fixed compatibility with Requests 2.5.1
* Changed the default JSON ``Content-Type`` to ``application/json`` as UTF-8
is the default JSON encoding
`0.9.1`_ (2015-02-07)
---------------------
* Added support for Requests transport adapter plugins
(see `httpie-unixsocket <https://github.com/msabramo/httpie-unixsocket>`_
and `httpie-http2 <https://github.com/jkbrzt/httpie-http2>`_)
`0.9.0`_ (2015-01-31)
---------------------
* Added ``--cert`` and ``--cert-key`` parameters to specify a client side
certificate and private key for SSL
* Improved unicode support
* Improved terminal color depth detection via ``curses``
* To make it easier to deal with Windows paths in request items, ``\``
now only escapes special characters (the ones that are used as key-value
separators by HTTPie)
* Switched from ``unittest`` to ``pytest``
* Added Python `wheel` support
* Various test suite improvements
* Added ``CONTRIBUTING``
* Fixed ``User-Agent`` overwriting when used within a session
* Fixed handling of empty passwords in URL credentials
* Fixed multiple file uploads with the same form field name
* Fixed ``--output=/dev/null`` on Linux
* Miscellaneous bugfixes
`0.8.0`_ (2014-01-25)
---------------------
* Added ``field=@file.txt`` and ``field:=@file.json`` for embedding
the contents of text and JSON files into request data
* Added curl-style shorthand for localhost
* Fixed request ``Host`` header value output so that it doesn't contain
credentials, if included in the URL
`0.7.1`_ (2013-09-24)
---------------------
* Added ``--ignore-stdin``
* Added support for auth plugins
* Improved ``--help`` output
* Improved ``Content-Disposition`` parsing for ``--download`` mode
* Update to Requests 2.0.0
`0.6.0`_ (2013-06-03)
---------------------
* XML data is now formatted
* ``--session`` and ``--session-read-only`` now also accept paths to
session files (eg. ``http --session=/tmp/session.json example.org``)
`0.5.1`_ (2013-05-13)
---------------------
* ``Content-*`` and ``If-*`` request headers are not stored in sessions
anymore as they are request-specific
`0.5.0`_ (2013-04-27)
---------------------
* Added a download mode via ``--download``
* Fixes miscellaneous bugs
`0.4.1`_ (2013-02-26)
---------------------
* Fixed ``setup.py``
`0.4.0`_ (2013-02-22)
---------------------
* Added Python 3.3 compatibility
* Added Requests >= v1.0.4 compatibility
* Added support for credentials in URL
* Added ``--no-option`` for every ``--option`` to be config-friendly
* Mutually exclusive arguments can be specified multiple times. The
last value is used
`0.3.0`_ (2012-09-21)
---------------------
* Allow output redirection on Windows
* Added configuration file
* Added persistent session support
* Renamed ``--allow-redirects`` to ``--follow``
* Improved the usability of ``http --help``
* Fixed installation on Windows with Python 3
* Fixed colorized output on Windows with Python 3
* CRLF HTTP header field separation in the output
* Added exit status code ``2`` for timed-out requests
* Added the option to separate colorizing and formatting
(``--pretty=all``, ``--pretty=colors`` and ``--pretty=format``)
``--ugly`` has bee removed in favor of ``--pretty=none``
`0.2.7`_ (2012-08-07)
---------------------
* Added compatibility with Requests 0.13.6
* Added streamed terminal output. ``--stream, -S`` can be used to enable
streaming also with ``--pretty`` and to ensure a more frequent output
flushing
* Added support for efficient large file downloads
* Sort headers by name (unless ``--pretty=none``)
* Response body is fetched only when needed (e.g., not with ``--headers``)
* Improved content type matching
* Updated Solarized color scheme
* Windows: Added ``--output FILE`` to store output into a file
(piping results in corrupted data on Windows)
* Proper handling of binary requests and responses
* Fixed printing of ``multipart/form-data`` requests
* Renamed ``--traceback`` to ``--debug``
`0.2.6`_ (2012-07-26)
---------------------
* The short option for ``--headers`` is now ``-h`` (``-t`` has been
removed, for usage use ``--help``)
* Form data and URL parameters can have multiple fields with the same name
(e.g.,``http -f url a=1 a=2``)
* Added ``--check-status`` to exit with an error on HTTP 3xx, 4xx and
5xx (3, 4, and 5, respectively)
* If the output is piped to another program or redirected to a file,
the default behaviour is to only print the response body
(It can still be overwritten via the ``--print`` flag.)
* Improved highlighting of HTTP headers
* Added query string parameters (``param==value``)
* Added support for terminal colors under Windows
`0.2.5`_ (2012-07-17)
---------------------
* Unicode characters in prettified JSON now don't get escaped for
improved readability
* --auth now prompts for a password if only a username provided
* Added support for request payloads from a file path with automatic
``Content-Type`` (``http URL @/path``)
* Fixed missing query string when displaying the request headers via
``--verbose``
* Fixed Content-Type for requests with no data
`0.2.2`_ (2012-06-24)
---------------------
* The ``METHOD`` positional argument can now be omitted (defaults to
``GET``, or to ``POST`` with data)
* Fixed --verbose --form
* Added support for Tox
`0.2.1`_ (2012-06-13)
---------------------
* Added compatibility with ``requests-0.12.1``
* Dropped custom JSON and HTTP lexers in favor of the ones newly included
in ``pygments-1.5``
`0.2.0`_ (2012-04-25)
---------------------
* Added Python 3 support
* Added the ability to print the HTTP request as well as the response
(see ``--print`` and ``--verbose``)
* Added support for Digest authentication
* Added file upload support
(``http -f POST file_field_name@/path/to/file``)
* Improved syntax highlighting for JSON
* Added support for field name escaping
* Many bug fixes
`0.1.6`_ (2012-03-04)
---------------------
* Fixed ``setup.py``
`0.1.5`_ (2012-03-04)
---------------------
* Many improvements and bug fixes
`0.1.4`_ (2012-02-28)
---------------------
* Many improvements and bug fixes
`0.1`_ (2012-02-25)
-------------------
* Initial public release
.. _`0.1`: https://github.com/jkbrzt/httpie/commit/b966efa
.. _0.1.4: https://github.com/jkbrzt/httpie/compare/b966efa...0.1.4
.. _0.1.5: https://github.com/jkbrzt/httpie/compare/0.1.4...0.1.5
.. _0.1.6: https://github.com/jkbrzt/httpie/compare/0.1.5...0.1.6
.. _0.2.0: https://github.com/jkbrzt/httpie/compare/0.1.6...0.2.0
.. _0.2.1: https://github.com/jkbrzt/httpie/compare/0.2.0...0.2.1
.. _0.2.2: https://github.com/jkbrzt/httpie/compare/0.2.1...0.2.2
.. _0.2.5: https://github.com/jkbrzt/httpie/compare/0.2.2...0.2.5
.. _0.2.6: https://github.com/jkbrzt/httpie/compare/0.2.5...0.2.6
.. _0.2.7: https://github.com/jkbrzt/httpie/compare/0.2.5...0.2.7
.. _0.3.0: https://github.com/jkbrzt/httpie/compare/0.2.7...0.3.0
.. _0.4.0: https://github.com/jkbrzt/httpie/compare/0.3.0...0.4.0
.. _0.4.1: https://github.com/jkbrzt/httpie/compare/0.4.0...0.4.1
.. _0.5.0: https://github.com/jkbrzt/httpie/compare/0.4.1...0.5.0
.. _0.5.1: https://github.com/jkbrzt/httpie/compare/0.5.0...0.5.1
.. _0.6.0: https://github.com/jkbrzt/httpie/compare/0.5.1...0.6.0
.. _0.7.1: https://github.com/jkbrzt/httpie/compare/0.6.0...0.7.1
.. _0.8.0: https://github.com/jkbrzt/httpie/compare/0.7.1...0.8.0
.. _0.9.0: https://github.com/jkbrzt/httpie/compare/0.8.0...0.9.0
.. _0.9.1: https://github.com/jkbrzt/httpie/compare/0.9.0...0.9.1
.. _0.9.2: https://github.com/jkbrzt/httpie/compare/0.9.1...0.9.2
.. _0.9.3: https://github.com/jkbrzt/httpie/compare/0.9.2...0.9.3
.. _1.0.0-dev: https://github.com/jkbrzt/httpie/compare/0.9.3...master

View File

@ -1,7 +1,7 @@
Contributing to HTTPie
######################
Bug reports and code and documentation patches are greatly appretiated. You can
Bug reports and code and documentation patches are greatly appreciated. You can
also help by using the development version of HTTPie and reporting any bugs you
might encounter.
@ -87,9 +87,9 @@ Don't forget to add yourself to `AUTHORS.rst`_.
.. _Tox: http://tox.testrun.org
.. _supported Python environments: https://github.com/jakubroztocil/httpie/blob/master/tox.ini
.. _existing issues: https://github.com/jakubroztocil/httpie/issues?state=open
.. _AUTHORS.rst: https://github.com/jakubroztocil/httpie/blob/master/AUTHORS.rst
.. _supported Python environments: https://github.com/jkbrzt/httpie/blob/master/tox.ini
.. _existing issues: https://github.com/jkbrzt/httpie/issues?state=open
.. _AUTHORS.rst: https://github.com/jkbrzt/httpie/blob/master/AUTHORS.rst
.. _pytest: http://pytest.org/
.. _Style Guide for Python Code: http://python.org/dev/peps/pep-0008/
.. _test suite: https://github.com/jakubroztocil/httpie/tree/master/tests
.. _test suite: https://github.com/jkbrzt/httpie/tree/master/tests

View File

@ -1,4 +1,4 @@
Copyright © 2012 Jakub Roztocil <jakub@roztocil.name>
Copyright © 2012-2015 Jakub Roztocil <jakub@roztocil.co>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

View File

@ -1 +1,4 @@
include README.rst LICENSE
include LICENSE
include README.rst
include CHANGELOG.rst
include AUTHORS.rst

View File

@ -2,34 +2,30 @@
HTTPie: a CLI, cURL-like tool for humans
****************************************
HTTPie (pronounced *aych-tee-tee-pie*) is a **command line HTTP client**. Its
goal is to make CLI interaction with web services as **human-friendly** as
possible. It provides a simple ``http`` command that allows for sending
HTTPie (pronounced *aitch-tee-tee-pie*) is a **command line HTTP client**.
Its goal is to make CLI interaction with web services as **human-friendly**
as possible. It provides a simple ``http`` command that allows for sending
arbitrary HTTP requests using a simple and natural syntax, and displays
colorized responses. HTTPie can be used for **testing, debugging**, and
colorized output. HTTPie can be used for **testing, debugging**, and
generally **interacting** with HTTP servers.
.. image:: https://github.com/jakubroztocil/httpie/raw/master/httpie.png
.. image:: https://raw.githubusercontent.com/jkbrzt/httpie/master/httpie.png
:alt: HTTPie compared to cURL
:width: 835
:height: 835
:width: 679
:height: 781
:align: center
------
.. image:: https://raw.github.com/claudiatd/httpie-artwork/master/images/httpie_logo_simple.png
:alt: HTTPie logo
:align: center
HTTPie is written in Python, and under the hood it uses the excellent
`Requests`_ and `Pygments`_ libraries.
**Table of Contents**
-----
|pypi| |unix_build| |windows_build| |coverage|
-----
.. contents::
@ -63,11 +59,6 @@ Installation
============
------------------------
Stable version |version|
------------------------
On **Mac OS X**, HTTPie can be installed via `Homebrew <http://brew.sh/>`_:
.. code-block:: bash
@ -75,9 +66,16 @@ On **Mac OS X**, HTTPie can be installed via `Homebrew <http://brew.sh/>`_:
$ brew install httpie
Most **Linux** distributions provide a package that can be installed via
system package manager, e.g. ``yum install httpie`` or ``apt-get install httpie``.
Note that the package might include a slightly older version of HTTPie.
Most **Linux** distributions provide a package that can be installed using the
system package manager, e.g.:
.. code-block:: bash
# Debian-based distributions such as Ubuntu:
$ apt-get install httpie
# RPM-based distributions:
$ yum install httpie
A **universal installation method** (that works on **Windows**, Mac OS X, Linux, …,
@ -86,24 +84,20 @@ and provides the latest version) is to use `pip`_:
.. code-block:: bash
# Make sure we have an up-to-date version of pip and setuptools:
$ pip install --upgrade pip setuptools
$ pip install --upgrade httpie
If the above fails, please use ``easy_install`` instead (``$ easy_install httpie``).
(If ``pip`` installation fails for some reason, you can try
``easy_install httpie`` as a fallback.)
-------------------
Development version
-------------------
============= =============
Mac/Linux Windows
|unix| |windows|
============= =============
The **latest development version** can be installed directly from GitHub:
.. code-block:: bash
@ -112,7 +106,7 @@ The **latest development version** can be installed directly from GitHub:
$ brew install httpie --HEAD
# Universal
$ pip install --upgrade https://github.com/jakubroztocil/httpie/tarball/master
$ pip install --upgrade https://github.com/jkbrzt/httpie/tarball/master
@ -165,12 +159,12 @@ See the request that is being sent using one of the `output options`_:
Use `Github API`_ to post a comment on an
`issue <https://github.com/jakubroztocil/httpie/issues/83>`_
`issue <https://github.com/jkbrzt/httpie/issues/83>`_
with `authentication`_:
.. code-block:: bash
$ http -a USERNAME POST https://api.github.com/repos/jakubroztocil/httpie/issues/83/comments body='HTTPie is awesome!'
$ http -a USERNAME POST https://api.github.com/repos/jkbrzt/httpie/issues/83/comments body='HTTPie is awesome!'
Upload a file using `redirected input`_:
@ -283,7 +277,7 @@ If the port is omitted, then port 80 is assumed.
GET / HTTP/1.1
Host: localhost
If find yourself manually constructing URLs with **querystring parameters**
If you find yourself manually constructing URLs with **querystring parameters**
on the terminal, you may appreciate the ``param==value`` syntax for appending
URL parameters so that you don't have to worry about escaping the ``&``
separators. To search for ``HTTPie`` on Google Images you could use this
@ -321,7 +315,7 @@ their type is distinguished only by the separator used:
+-----------------------+-----------------------------------------------------+
| URL parameters | Appends the given name/value pair as a query |
| ``name==value`` | string parameter to the URL. |
| | The ``==`` separator is used |
| | The ``==`` separator is used. |
+-----------------------+-----------------------------------------------------+
| Data Fields | Request data fields to be serialized as a JSON |
| ``field=value``, | object (default), or to be form-encoded |
@ -362,7 +356,7 @@ object by default. HTTPie also automatically sets the following headers,
both of which can be overwritten:
================ =======================================
``Content-Type`` ``application/json; charset=utf-8``
``Content-Type`` ``application/json``
``Accept`` ``application/json``
================ =======================================
@ -381,8 +375,8 @@ Simple example:
PUT / HTTP/1.1
Accept: application/json
Accept-Encoding: identity, deflate, compress, gzip
Content-Type: application/json; charset=utf-8
Accept-Encoding: gzip, deflate
Content-Type: application/json
Host: example.org
{
@ -408,7 +402,7 @@ fields using ``=@`` and ``:=@``:
PUT /person/1 HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
Content-Type: application/json
Host: api.example.com
{
@ -452,7 +446,8 @@ Regular Forms
.. code-block:: bash
$ http --form POST api.example.org/person/1 name='John Smith' email=john@example.org cv=@~/Documents/cv.txt
$ http --form POST api.example.org/person/1 name='John Smith' \
email=john@example.org cv=@~/Documents/cv.txt
.. code-block:: http
@ -497,14 +492,15 @@ To set custom headers you can use the ``Header:Value`` notation:
.. code-block:: bash
$ http example.org User-Agent:Bacon/1.0 'Cookie:valued-visitor=yes;foo=bar' X-Foo:Bar Referer:http://httpie.org/
$ http example.org User-Agent:Bacon/1.0 'Cookie:valued-visitor=yes;foo=bar' \
X-Foo:Bar Referer:http://httpie.org/
.. code-block:: http
GET / HTTP/1.1
Accept: */*
Accept-Encoding: identity, deflate, compress, gzip
Accept-Encoding: gzip, deflate
Cookie: valued-visitor=yes;foo=bar
Host: example.org
Referer: http://httpie.org/
@ -518,7 +514,7 @@ There are a couple of default headers that HTTPie sets:
GET / HTTP/1.1
Accept: */*
Accept-Encoding: identity, deflate, compress, gzip
Accept-Encoding: gzip, deflate
User-Agent: HTTPie/<version>
Host: <taken-from-URL>
@ -538,7 +534,7 @@ The currently supported authentication schemes are Basic and Digest
the argument. Or, if you only specify a username
(``-a username``), you'll be prompted for
the password before the request is sent.
To send a an empty password, pass ``username:``.
To send an empty password, pass ``username:``.
The ``username:password@hostname`` URL syntax is
supported as well (but credentials passed via ``-a``
have higher priority).
@ -591,10 +587,13 @@ Authorization information from your ``~/.netrc`` file is honored as well:
Auth Plugins
------------
* `httpie-oauth <https://github.com/jakubroztocil/httpie-oauth>`_: OAuth
* `httpie-ntlm <https://github.com/jakubroztocil/httpie-ntlm>`_: NTLM (NT LAN Manager)
* `httpie-oauth <https://github.com/jkbrzt/httpie-oauth>`_: OAuth
* `httpie-ntlm <https://github.com/jkbrzt/httpie-ntlm>`_: NTLM (NT LAN Manager)
* `httpie-negotiate <https://github.com/ndzou/httpie-negotiate>`_: SPNEGO (GSS Negotiate)
* `requests-hawk <https://github.com/mozilla-services/requests-hawk>`_: Hawk
* `httpie-api-auth <https://github.com/pd/httpie-api-auth>`_: ApiAuth
* `httpie-edgegrid <https://github.com/akamai-open/httpie-edgegrid>`_: EdgeGrid
* `httpie-jwt-auth <https://github.com/teracyhq/httpie-jwt-auth>`_: JWTAuth (JSON Web Tokens)
=======
@ -725,8 +724,8 @@ documentation examples:
$ http --verbose PUT httpbin.org/put hello=world
PUT /put HTTP/1.1
Accept: application/json
Accept-Encoding: identity, deflate, compress, gzip
Content-Type: application/json; charset=utf-8
Accept-Encoding: gzip, deflate
Content-Type: application/json
Host: httpbin.org
User-Agent: HTTPie/0.2.7dev
@ -826,7 +825,7 @@ You can even pipe web services together using HTTPie:
.. code-block:: bash
$ http GET https://api.github.com/repos/jakubroztocil/httpie | http POST httpbin.org/post
$ http GET https://api.github.com/repos/jkbrzt/httpie | http POST httpbin.org/post
You can use ``cat`` to enter multiline data on the terminal:
@ -896,7 +895,7 @@ Colors and Formatting
---------------------
Syntax highlighting is applied to HTTP headers and bodies (where it makes
sense). You can choose your prefered color scheme via the ``--style`` option
sense). You can choose your preferred color scheme via the ``--style`` option
if you don't like the default one (see ``$ http --help`` for the possible
values).
@ -1010,19 +1009,19 @@ is being saved to a file.
.. code-block:: bash
$ http --download https://github.com/jakubroztocil/httpie/tarball/master
$ http --download https://github.com/jkbrzt/httpie/tarball/master
.. code-block:: http
HTTP/1.1 200 OK
Connection: keep-alive
Content-Disposition: attachment; filename=jakubroztocil-httpie-0.4.1-33-gfc4f70a.tar.gz
Content-Disposition: attachment; filename=jkbrzt-httpie-0.4.1-33-gfc4f70a.tar.gz
Content-Length: 505530
Content-Type: application/x-gzip
Server: GitHub.com
Vary: Accept-Encoding
Downloading 494.89 kB to "jakubroztocil-httpie-0.4.1-33-gfc4f70a.tar.gz"
Downloading 494.89 kB to "jkbrzt-httpie-0.4.1-33-gfc4f70a.tar.gz"
/ 21.01% 104.00 kB 47.55 kB/s 0:00:08 ETA
@ -1036,7 +1035,7 @@ headers and progress are still shown in the terminal:
.. code-block:: bash
$ http -d https://github.com/jakubroztocil/httpie/tarball/master | tar zxf -
$ http -d https://github.com/jkbrzt/httpie/tarball/master | tar zxf -
If ``--output, -o`` is specified, you can resume a partial download using the
@ -1276,14 +1275,17 @@ and usage from scripts, where HTTPie serves as a generic HTTP client.
As HTTPie is still under heavy development, the existing command line
syntax and some of the ``--OPTIONS`` may change slightly before
HTTPie reaches its final version ``1.0``. All changes are recorded in the
`changelog`_.
`change log`_.
==========
Contribute
==========
Please see `CONTRIBUTING`_.
=======
Authors
=======
`Jakub Roztocil`_ (`@jkbrzt`_) created HTTPie and `these fine people`_
have contributed.
====
@ -1292,184 +1294,51 @@ Logo
Please see `claudiatd/httpie-artwork`_
=======
Authors
=======
`Jakub Roztocil`_ (`@jakubroztocil`_) created HTTPie and `these fine people`_
have contributed.
==========
Contribute
==========
Please see `CONTRIBUTING <https://github.com/jkbrzt/httpie/blob/master/CONTRIBUTING.rst>`_.
==========
Change Log
==========
Please see `CHANGELOG <https://github.com/jkbrzt/httpie/blob/master/CHANGELOG.rst>`_.
=======
Licence
=======
Please see `LICENSE`_.
Please see `LICENSE <https://github.com/jkbrzt/httpie/blob/master/LICENSE>`_.
=========
Changelog
=========
*You can click a version name to see a diff with the previous one.*
* `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
.. _Pygments: http://pygments.org/
.. _pip: http://www.pip-installer.org/en/latest/index.html
.. _Github API: http://developer.github.com/v3/issues/comments/#create-a-comment
.. _these fine people: https://github.com/jakubroztocil/httpie/contributors
.. _Jakub Roztocil: http://subtleapps.com
.. _@jakubroztocil: https://twitter.com/jakubroztocil
.. _these fine people: https://github.com/jkbrzt/httpie/contributors
.. _Jakub Roztocil: http://roztocil.co
.. _@jkbrzt: https://twitter.com/jkbrzt
.. _claudiatd/httpie-artwork: https://github.com/claudiatd/httpie-artwork
.. _0.1.6: https://github.com/jakubroztocil/httpie/compare/0.1.4...0.1.6
.. _0.2.0: https://github.com/jakubroztocil/httpie/compare/0.1.6...0.2.0
.. _0.2.1: https://github.com/jakubroztocil/httpie/compare/0.2.0...0.2.1
.. _0.2.2: https://github.com/jakubroztocil/httpie/compare/0.2.1...0.2.2
.. _0.2.5: https://github.com/jakubroztocil/httpie/compare/0.2.2...0.2.5
.. _0.2.6: https://github.com/jakubroztocil/httpie/compare/0.2.5...0.2.6
.. _0.2.7: https://github.com/jakubroztocil/httpie/compare/0.2.5...0.2.7
.. _0.3.0: https://github.com/jakubroztocil/httpie/compare/0.2.7...0.3.0
.. _0.4.0: https://github.com/jakubroztocil/httpie/compare/0.3.0...0.4.0
.. _0.4.1: https://github.com/jakubroztocil/httpie/compare/0.4.0...0.4.1
.. _0.5.0: https://github.com/jakubroztocil/httpie/compare/0.4.1...0.5.0
.. _0.5.1: https://github.com/jakubroztocil/httpie/compare/0.5.0...0.5.1
.. _0.6.0: https://github.com/jakubroztocil/httpie/compare/0.5.1...0.6.0
.. _0.7.1: https://github.com/jakubroztocil/httpie/compare/0.6.0...0.7.1
.. _0.8.0: https://github.com/jakubroztocil/httpie/compare/0.7.1...0.8.0
.. _0.9.0: https://github.com/jakubroztocil/httpie/compare/0.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
:target: http://badge.fury.io/py/httpie
.. |pypi| image:: https://img.shields.io/pypi/v/httpie.svg?style=flat-square&label=latest%20version
:target: https://pypi.python.org/pypi/httpie
:alt: Latest version released on PyPi
.. |unix| image:: https://api.travis-ci.org/jakubroztocil/httpie.svg
:target: http://travis-ci.org/jakubroztocil/httpie
:alt: Build Status of the master branch on Mac/Linux
.. |coverage| image:: https://img.shields.io/coveralls/jkbrzt/httpie/master.svg?style=flat-square
:target: https://coveralls.io/r/jkbrzt/httpie?branch=master
:alt: Test coverage
.. |windows| image:: https://ci.appveyor.com/api/projects/status/f7b5dogxuseq8srw
:target: https://ci.appveyor.com/project/jakubroztocil/httpie
:alt: Build Status of the master branch on Windows
.. |unix_build| image:: https://img.shields.io/travis/jkbrzt/httpie/master.svg?style=flat-square&label=unix%20build
:target: http://travis-ci.org/jkbrzt/httpie
:alt: Build status of the master branch on Mac/Linux
.. |windows_build| image:: https://img.shields.io/appveyor/ci/jkbrzt/httpie.svg?style=flat-square&label=windows%20build
:target: https://ci.appveyor.com/project/jkbrzt/httpie
:alt: Build status of the master branch on Windows

View File

@ -1,4 +1,4 @@
# https://ci.appveyor.com/project/jakubroztocil/httpie
# https://ci.appveyor.com/project/jkbrzt/httpie
build: false
environment:
matrix:
@ -8,8 +8,9 @@ init:
- "ECHO %PYTHON%"
- ps: "ls C:/Python*"
install:
- ps: (new-object net.webclient).DownloadFile('https://raw.github.com/pypa/pip/master/contrib/get-pip.py', 'C:/get-pip.py')
- "%PYTHON%/python.exe C:/get-pip.py"
# - ps: (new-object net.webclient).DownloadFile('https://bootstrap.pypa.io/get-pip.py', 'C:/get-pip.py')
# - "%PYTHON%/python.exe C:/get-pip.py"
- "%PYTHON%/Scripts/pip.exe install -U pip setuptools"
- "%PYTHON%/Scripts/pip.exe install -e ."
test_script:
- "%PYTHON%/Scripts/pip.exe --version"

23
httpie-completion.bash Normal file
View 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" ) )
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 446 KiB

After

Width:  |  Height:  |  Size: 182 KiB

View File

@ -3,7 +3,7 @@ HTTPie - a CLI, cURL-like tool for humans.
"""
__author__ = 'Jakub Roztocil'
__version__ = '0.9.0'
__version__ = '0.9.3'
__licence__ = 'BSD'

View File

@ -4,7 +4,7 @@ NOTE: the CLI interface may change before reaching v1.0.
"""
from textwrap import dedent, wrap
#noinspection PyCompatibility
# noinspection PyCompatibility
from argparse import (RawDescriptionHelpFormatter, FileType,
OPTIONAL, ZERO_OR_MORE, SUPPRESS)
@ -49,7 +49,7 @@ parser = Parser(
Suggestions and bug reports are greatly appreciated:
https://github.com/jakubroztocil/httpie/issues
https://github.com/jkbrzt/httpie/issues
""")
)

View File

@ -3,6 +3,7 @@ import sys
from pprint import pformat
import requests
from requests.packages import urllib3
from httpie import sessions
from httpie import __version__
@ -10,21 +11,44 @@ from httpie.compat import str
from httpie.plugins import plugin_manager
try:
# https://urllib3.readthedocs.org/en/latest/security.html
urllib3.disable_warnings()
except AttributeError:
# In some rare cases, the user may have an old version of the requests
# or urllib3, and there is no method called "disable_warnings." In these
# cases, we don't need to call the method.
# They may get some noisy output but execution shouldn't die. Move on.
pass
FORM = 'application/x-www-form-urlencoded; charset=utf-8'
JSON = 'application/json; charset=utf-8'
JSON = 'application/json'
DEFAULT_UA = 'HTTPie/%s' % __version__
def get_requests_session():
requests_session = requests.Session()
for cls in plugin_manager.get_transport_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):
"""Send the request and return a `request.Response`."""
requests_session = get_requests_session()
if not args.session and not args.session_read_only:
requests_kwargs = get_requests_kwargs(args)
kwargs = get_requests_kwargs(args)
if args.debug:
dump_request(requests_kwargs)
response = requests.request(**requests_kwargs)
dump_request(kwargs)
response = requests_session.request(**kwargs)
else:
response = sessions.get_response(
requests_session=requests_session,
args=args,
config_dir=config_dir,
session_name=args.session or args.session_read_only,
@ -35,13 +59,13 @@ def get_response(args, config_dir):
def dump_request(kwargs):
sys.stderr.write('\n>>> requests.request(%s)\n\n'
sys.stderr.write('\n>>> requests.request(**%s)\n\n'
% pformat(kwargs))
def encode_headers(headers):
# This allows for unicode headers which is non-standard but practical.
# See: https://github.com/jakubroztocil/httpie/issues/212
# See: https://github.com/jkbrzt/httpie/issues/212
return dict(
(name, value.encode('utf8') if isinstance(value, str) else value)
for name, value in headers.items()
@ -75,7 +99,7 @@ def get_requests_kwargs(args, base_headers=None):
# Serialize JSON data, if needed.
data = args.data
auto_json = data and not args.form
if args.json or auto_json and isinstance(data, dict):
if (args.json or auto_json) and isinstance(data, dict):
if data:
data = json.dumps(data)
else:

View File

@ -2,27 +2,42 @@
Python 2.6, 2.7, and 3.x compatibility.
"""
# Borrow these from requests:
# noinspection PyUnresolvedReferences
from requests.compat import is_windows, bytes, str, is_py3, is_py26
import sys
try:
is_py2 = sys.version_info[0] == 2
is_py26 = sys.version_info[:2] == (2, 6)
is_py27 = sys.version_info[:2] == (2, 7)
is_py3 = sys.version_info[0] == 3
is_pypy = 'pypy' in sys.version.lower()
is_windows = 'win32' in str(sys.platform).lower()
if is_py2:
bytes = str
str = unicode
elif is_py3:
str = str
bytes = bytes
try: # pragma: no cover
# noinspection PyUnresolvedReferences,PyCompatibility
from urllib.parse import urlsplit
except ImportError:
except ImportError: # pragma: no cover
# noinspection PyUnresolvedReferences,PyCompatibility
from urlparse import urlsplit
try:
try: # pragma: no cover
# noinspection PyCompatibility
from urllib.request import urlopen
except ImportError:
except ImportError: # pragma: no cover
# noinspection PyCompatibility
from urllib2 import urlopen
try:
try: # pragma: no cover
from collections import OrderedDict
except ImportError:
except ImportError: # pragma: no cover
# Python 2.6 OrderedDict class, needed for headers, parameters, etc .###
# <https://pypi.python.org/pypi/ordereddict/1.1>
# noinspection PyCompatibility

View File

@ -80,7 +80,7 @@ class BaseConfigDict(dict):
class Config(BaseConfigDict):
name = 'config'
helpurl = 'https://github.com/jakubroztocil/httpie#config'
helpurl = 'https://github.com/jkbrzt/httpie#config'
about = 'HTTPie configuration file'
DEFAULTS = {

View File

@ -1,7 +1,6 @@
import sys
from requests.compat import is_windows
from httpie.compat import is_windows
from httpie.config import DEFAULT_CONFIG_DIR, Config

View File

@ -67,7 +67,7 @@ def decode_args(args, stdin_encoding):
]
def main(args=sys.argv[1:], env=Environment()):
def main(args=sys.argv[1:], env=Environment(), error=None):
"""Run the main program and write the output to ``env.stdout``.
Return exit status code.
@ -81,11 +81,14 @@ def main(args=sys.argv[1:], env=Environment()):
if env.config.default_options:
args = env.config.default_options + args
def error(msg, *args, **kwargs):
def _error(msg, *args, **kwargs):
msg = msg % args
level = kwargs.get('level', 'error')
env.stderr.write('\nhttp: %s: %s\n' % (level, msg))
if error is None:
error = _error
debug = '--debug' in args
traceback = debug or '--traceback' in args
exit_status = ExitStatus.OK
@ -183,7 +186,13 @@ def main(args=sys.argv[1:], env=Environment()):
# Network errors vs. bugs, etc.
if traceback:
raise
error('%s: %s', type(e).__name__, str(e))
msg = str(e)
if hasattr(e, 'request'):
request = e.request
if hasattr(request, 'url'):
msg += ' while doing %s request to URL: %s' % (
request.method, request.url)
error('%s: %s', type(e).__name__, msg)
exit_status = ExitStatus.ERROR
finally:

View File

@ -104,7 +104,7 @@ def filename_from_content_disposition(content_disposition):
:return: the filename if present and valid, otherwise `None`
"""
# attachment; filename=jakubroztocil-httpie-0.4.1-20-g40bd8f6.tar.gz
# attachment; filename=jkbrzt-httpie-0.4.1-20-g40bd8f6.tar.gz
msg = Message('Content-Disposition: %s' % content_disposition)
filename = msg.get_filename()

View File

@ -8,19 +8,23 @@ import errno
import mimetypes
import getpass
from io import BytesIO
from collections import namedtuple
from collections import namedtuple, Iterable
# noinspection PyCompatibility
from argparse import ArgumentParser, ArgumentTypeError, ArgumentError
# TODO: Use MultiDict for headers once added to `requests`.
# https://github.com/jakubroztocil/httpie/issues/130
# https://github.com/jkbrzt/httpie/issues/130
from requests.structures import CaseInsensitiveDict
from httpie.compat import OrderedDict, urlsplit, str
from httpie.compat import OrderedDict, urlsplit, str, is_pypy, is_py27
from httpie.sessions import VALID_SESSION_NAME_PATTERN
from httpie.utils import load_json_preserve_order
# 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_GET = 'GET'
HTTP = 'http://'
@ -132,7 +136,7 @@ class Parser(ArgumentParser):
self._parse_items()
if not self.args.ignore_stdin and not env.stdin_isatty:
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
# See if we're using curl style shorthand for localhost (:3000/foo)
@ -299,8 +303,8 @@ class Parser(ArgumentParser):
# Infer the method
has_data = (
(not self.args.ignore_stdin and not self.env.stdin_isatty)
or any(item.sep in SEP_GROUP_DATA_ITEMS
for item in self.args.items)
or any(item.sep in SEP_GROUP_DATA_ITEMS
for item in self.args.items)
)
self.args.method = HTTP_POST if has_data else HTTP_GET
@ -374,7 +378,8 @@ class Parser(ArgumentParser):
if self.args.prettify == PRETTY_STDOUT_TTY_ONLY:
self.args.prettify = PRETTY_MAP[
'all' if self.env.stdout_isatty else 'none']
elif self.args.prettify and self.env.is_windows:
elif (self.args.prettify and self.env.is_windows and
self.args.output_file):
self.error('Only terminal output can be colorized on Windows.')
else:
# noinspection PyTypeChecker
@ -517,7 +522,7 @@ class AuthCredentials(KeyValue):
def _getpass(self, prompt):
# To allow mocking.
return getpass.getpass(prompt)
return getpass.getpass(str(prompt))
def has_password(self):
return self.value is not None
@ -557,7 +562,18 @@ class AuthCredentialsArgType(KeyValueArgType):
class RequestItemsDict(OrderedDict):
"""Multi-value dict for URL parameters and form data."""
#noinspection PyMethodOverriding
if is_pypy and is_py27:
# Manually set keys when initialized with an iterable as PyPy
# doesn't call __setitem__ in such case (pypy3 does).
def __init__(self, *args, **kwargs):
if len(args) == 1 and isinstance(args[0], Iterable):
super(RequestItemsDict, self).__init__(**kwargs)
for k, v in args[0]:
self[k] = v
else:
super(RequestItemsDict, self).__init__(*args, **kwargs)
# noinspection PyMethodOverriding
def __setitem__(self, key, value):
""" If `key` is assigned more than once, `self[key]` holds a
`list` of all the values.

View File

@ -52,7 +52,14 @@ class HTTPResponse(HTTPMessage):
@property
def headers(self):
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(
version=version,
status=original.status,

View File

@ -7,7 +7,6 @@ from pygments.formatters.terminal import TerminalFormatter
from pygments.formatters.terminal256 import Terminal256Formatter
from pygments.util import ClassNotFound
from httpie.compat import is_windows
from httpie.plugins import FormatterPlugin
@ -15,7 +14,7 @@ from httpie.plugins import FormatterPlugin
# great and fruity seems to give the best result there.
AVAILABLE_STYLES = set(pygments.styles.STYLE_MAP.keys())
AVAILABLE_STYLES.add('solarized')
DEFAULT_STYLE = 'solarized' if not is_windows else 'fruity'
DEFAULT_STYLE = 'monokai'
class ColorFormatter(FormatterPlugin):
@ -144,6 +143,8 @@ class HTTPLexer(pygments.lexer.RegexLexer):
}
# TODO: As Solarized is not the default theme any longer, it should be removed
# or bundled directly with Pygments so that we don't need to support it.
class Solarized256Style(pygments.style.Style):
"""
solarized256

View File

@ -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.builtin import BasicAuthPlugin, DigestAuthPlugin
from httpie.output.formatters.headers import HeadersFormatter

View File

@ -15,7 +15,7 @@ class AuthPlugin(BasePlugin):
"""
Base auth plugin class.
See <https://github.com/jkbr/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
@ -30,6 +30,25 @@ class AuthPlugin(BasePlugin):
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):
def __init__(self, mime):

View File

@ -16,7 +16,7 @@ class HTTPBasicAuth(requests.auth.HTTPBasicAuth):
"""
Override username/password serialization to allow unicode.
See https://github.com/jakubroztocil/httpie/issues/212
See https://github.com/jkbrzt/httpie/issues/212
"""
r.headers['Authorization'] = type(self).make_header(

View File

@ -1,12 +1,14 @@
from itertools import groupby
from pkg_resources import iter_entry_points
from httpie.plugins import AuthPlugin, FormatterPlugin, ConverterPlugin
from httpie.plugins.base import TransportPlugin
ENTRY_POINT_NAMES = [
'httpie.plugins.auth.v1',
'httpie.plugins.formatter.v1',
'httpie.plugins.converter.v1',
'httpie.plugins.transport.v1',
]
@ -56,3 +58,8 @@ class PluginManager(object):
def get_converters(self):
return [plugin for plugin in self
if issubclass(plugin, ConverterPlugin)]
# Adapters
def get_transport_plugins(self):
return [plugin for plugin in self
if issubclass(plugin, TransportPlugin)]

View File

@ -4,7 +4,6 @@
import re
import os
import requests
from requests.cookies import RequestsCookieJar, create_cookie
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-']
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
aspects of the session to the request.
@ -32,7 +32,9 @@ def get_response(session_name, config_dir, args, read_only=False):
else:
hostname = (args.headers.get('Host', None)
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
hostname = hostname.replace(':', '_')
@ -44,10 +46,10 @@ def get_response(session_name, config_dir, args, read_only=False):
session = Session(path)
session.load()
requests_kwargs = get_requests_kwargs(args, base_headers=session.headers)
kwargs = get_requests_kwargs(args, base_headers=session.headers)
if args.debug:
dump_request(requests_kwargs)
session.update_headers(requests_kwargs['headers'])
dump_request(kwargs)
session.update_headers(kwargs['headers'])
if args.auth:
session.auth = {
@ -56,13 +58,12 @@ def get_response(session_name, config_dir, args, read_only=False):
'password': args.auth.value,
}
elif session.auth:
requests_kwargs['auth'] = session.auth
kwargs['auth'] = session.auth
requests_session = requests.Session()
requests_session.cookies = session.cookies
try:
response = requests_session.request(**requests_kwargs)
response = requests_session.request(**kwargs)
except Exception:
raise
else:
@ -74,7 +75,7 @@ def get_response(session_name, config_dir, args, read_only=False):
class Session(BaseConfigDict):
helpurl = 'https://github.com/jakubroztocil/httpie#sessions'
helpurl = 'https://github.com/jkbrzt/httpie#sessions'
about = 'HTTPie session file'
def __init__(self, path, *args, **kwargs):

View File

@ -54,4 +54,3 @@ def humanize_bytes(n, precision=2):
# noinspection PyUnboundLocalVariable
return '%.*f %s' % (precision, n / factor, suffix)

3
pytest.ini Normal file
View File

@ -0,0 +1,3 @@
[pytest]
addopts = --tb=native
norecursedirs = tests/fixtures

View File

@ -1,6 +1,7 @@
tox
mock
pytest
pytest-cov
pytest-httpbin
pytest-httpbin>=0.0.6
docutils
wheel

View File

@ -14,7 +14,6 @@ class PyTest(TestCommand):
# and runs the tests with no fancy stuff like parallel execution.
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_suite = True
self.test_args = [
'--doctest-modules', '--verbose',
'./httpie', './tests'
@ -31,6 +30,7 @@ tests_require = [
# https://bitbucket.org/pypa/setuptools/issue/196/
'pytest-httpbin',
'pytest',
'mock',
]
@ -39,12 +39,12 @@ install_requires = [
'Pygments>=1.5'
]
### Conditional dependencies:
# Conditional dependencies:
# sdist
if not 'bdist_wheel' in sys.argv:
if 'bdist_wheel' not in sys.argv:
try:
#noinspection PyUnresolvedReferences
# noinspection PyUnresolvedReferences
import argparse
except ImportError:
install_requires.append('argparse>=1.2.1')
@ -74,9 +74,9 @@ setup(
description=httpie.__doc__.strip(),
long_description=long_description(),
url='http://httpie.org/',
download_url='https://github.com/jakubroztocil/httpie',
download_url='https://github.com/jkbrzt/httpie',
author=httpie.__author__,
author_email='jakub@roztocil.name',
author_email='jakub@roztocil.co',
license=httpie.__licence__,
packages=find_packages(),
entry_points={

View File

@ -5,4 +5,4 @@ HTTPie Test Suite
Please see `CONTRIBUTING`_.
.. _CONTRIBUTING: https://github.com/jakubroztocil/httpie/blob/master/CONTRIBUTING.rst
.. _CONTRIBUTING: https://github.com/jkbrzt/httpie/blob/master/CONTRIBUTING.rst

View File

@ -38,4 +38,3 @@ with open(BIN_FILE_PATH, 'rb') as f:
BIN_FILE_CONTENT = f.read()
UNICODE = FILE_CONTENT

View File

@ -52,11 +52,10 @@ class TestAuth:
])
def test_only_username_in_url(self, url):
"""
https://github.com/jakubroztocil/httpie/issues/242
https://github.com/jkbrzt/httpie/issues/242
"""
args = httpie.cli.parser.parse_args(args=[url], env=TestEnvironment())
assert args.auth
assert args.auth.key == 'username'
assert args.auth.value == ''

View File

@ -2,9 +2,9 @@
import json
# noinspection PyCompatibility
import argparse
import os
import pytest
from requests.exceptions import InvalidSchema
from httpie import input
from httpie.input import KeyValue, KeyValueArgType, DataDict
@ -321,3 +321,12 @@ class TestIgnoreStdin:
error_exit_ok=True)
assert r.exit_status == ExitStatus.ERROR
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')

View File

@ -42,7 +42,7 @@ class TestAutoContentTypeAndAcceptHeaders:
"""
def test_GET_no_data_no_auto_headers(self, httpbin):
# https://github.com/jakubroztocil/httpie/issues/62
# https://github.com/jkbrzt/httpie/issues/62
r = http('GET', httpbin.url + '/headers')
assert HTTP_OK in r
assert r.json['headers']['Accept'] == '*/*'
@ -59,21 +59,21 @@ class TestAutoContentTypeAndAcceptHeaders:
r = http('POST', httpbin.url + '/post', 'a=b')
assert HTTP_OK in r
assert '"Accept": "application/json"' in r
assert '"Content-Type": "application/json; charset=utf-8' in r
assert '"Content-Type": "application/json' in r
def test_GET_with_data_auto_JSON_headers(self, httpbin):
# JSON headers should automatically be set also for GET with data.
r = http('POST', httpbin.url + '/post', 'a=b')
assert HTTP_OK in r
assert '"Accept": "application/json"' in r, r
assert '"Content-Type": "application/json; charset=utf-8' in r
assert '"Content-Type": "application/json' in r
def test_POST_explicit_JSON_auto_JSON_accept(self, httpbin):
r = http('--json', 'POST', httpbin.url + '/post')
assert HTTP_OK in r
assert r.json['headers']['Accept'] == 'application/json'
# Make sure Content-Type gets set even with no data.
# https://github.com/jakubroztocil/httpie/issues/137
# https://github.com/jkbrzt/httpie/issues/137
assert 'application/json' in r.json['headers']['Content-Type']
def test_GET_explicit_JSON_explicit_headers(self, httpbin):

View File

@ -9,7 +9,7 @@ from utils import TESTS_ROOT
def has_docutils():
try:
#noinspection PyUnresolvedReferences
# noinspection PyUnresolvedReferences
import docutils
return True
except ImportError:
@ -32,8 +32,8 @@ assert filenames
def test_rst_file_syntax(filename):
p = subprocess.Popen(
['rst2pseudoxml.py', '--report=1', '--exit-status=1', filename],
stderr=subprocess.PIPE,
stdout=subprocess.PIPE
stderr=subprocess.PIPE,
stdout=subprocess.PIPE
)
err = p.communicate()[1]
assert p.returncode == 0, err

48
tests/test_errors.py Normal file
View 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).'

View File

@ -18,7 +18,7 @@ class TestHTTPie:
def test_help(self):
r = http('--help', error_exit_ok=True)
assert r.exit_status == httpie.ExitStatus.OK
assert 'https://github.com/jakubroztocil/httpie/issues' in r
assert 'https://github.com/jkbrzt/httpie/issues' in r
def test_version(self):
r = http('--version', error_exit_ok=True)

View File

@ -1,8 +1,8 @@
import pytest
from utils import TestEnvironment, http, HTTP_OK, COLOR, CRLF
from httpie import ExitStatus
from httpie.output.formatters.colors import get_lexer
from utils import TestEnvironment, http, HTTP_OK, COLOR, CRLF
class TestVerboseFlag:
@ -13,7 +13,7 @@ class TestVerboseFlag:
assert r.count('__test__') == 2
def test_verbose_form(self, httpbin):
# https://github.com/jakubroztocil/httpie/issues/53
# https://github.com/jkbrzt/httpie/issues/53
r = http('--verbose', '--form', 'POST', httpbin.url + '/post',
'A=B', 'C=D')
assert HTTP_OK in r

View File

@ -7,7 +7,7 @@ from httpie.compat import is_windows
def test_Host_header_overwrite(httpbin):
"""
https://github.com/jakubroztocil/httpie/issues/235
https://github.com/jkbrzt/httpie/issues/235
"""
host = 'httpbin.org'
@ -21,7 +21,7 @@ def test_Host_header_overwrite(httpbin):
@pytest.mark.skipif(is_windows, reason='Unix-only')
def test_output_devnull(httpbin):
"""
https://github.com/jakubroztocil/httpie/issues/252
https://github.com/jkbrzt/httpie/issues/252
"""
http('--output=/dev/null', httpbin + '/get')

View File

@ -1,6 +1,9 @@
# coding=utf-8
import os
import shutil
import sys
import pytest
from httpie.plugins.builtin import HTTPBasicAuth
from utils import TestEnvironment, mk_config_dir, http, HTTP_OK, \
@ -61,17 +64,20 @@ class TestSessionFlow(SessionTestBase):
def test_session_update(self, httpbin):
self.start_session(httpbin)
# Get a response to a request from the original session.
r2 = http('--session=test', 'GET', httpbin.url + '/get', env=self.env())
r2 = http('--session=test', 'GET', httpbin.url + '/get',
env=self.env())
assert HTTP_OK in r2
# Make a request modifying the session data.
r3 = http('--follow', '--session=test', '--auth=username:password2',
'GET', httpbin.url + '/cookies/set?hello=world2', 'Hello:World2',
'GET', httpbin.url + '/cookies/set?hello=world2',
'Hello:World2',
env=self.env())
assert HTTP_OK in r3
# Get a response to a request from the updated session.
r4 = http('--session=test', 'GET', httpbin.url + '/get', env=self.env())
r4 = http('--session=test', 'GET', httpbin.url + '/get',
env=self.env())
assert HTTP_OK in r4
assert r4.json['headers']['Hello'] == 'World2'
assert r4.json['headers']['Cookie'] == 'hello=world2'
@ -81,7 +87,8 @@ class TestSessionFlow(SessionTestBase):
def test_session_read_only(self, httpbin):
self.start_session(httpbin)
# Get a response from the original session.
r2 = http('--session=test', 'GET', httpbin.url + '/get', env=self.env())
r2 = http('--session=test', 'GET', httpbin.url + '/get',
env=self.env())
assert HTTP_OK in r2
# Make a request modifying the session data but
@ -93,7 +100,8 @@ class TestSessionFlow(SessionTestBase):
assert HTTP_OK in r3
# Get a response from the updated session.
r4 = http('--session=test', 'GET', httpbin.url + '/get', env=self.env())
r4 = http('--session=test', 'GET', httpbin.url + '/get',
env=self.env())
assert HTTP_OK in r4
# Origin can differ on Travis.
@ -114,8 +122,8 @@ class TestSession(SessionTestBase):
'If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT',
env=self.env())
assert HTTP_OK in r1
r2 = http('--session=test', 'GET', httpbin.url + '/get', env=self.env())
r2 = http('--session=test', 'GET', httpbin.url + '/get',
env=self.env())
assert HTTP_OK in r2
assert no_content_type(r2.json['headers'])
assert 'If-Unmodified-Since' not in r2.json['headers']
@ -132,6 +140,10 @@ class TestSession(SessionTestBase):
assert HTTP_OK in r2
assert r2.json['headers']['Foo'] == 'Bar'
@pytest.mark.skipif(
sys.version_info >= (3,),
reason="This test fails intermittently on Python 3 - "
"see https://github.com/jkbrzt/httpie/issues/282")
def test_session_unicode(self, httpbin):
self.start_session(httpbin)
@ -152,7 +164,7 @@ class TestSession(SessionTestBase):
def test_session_default_header_value_overwritten(self, httpbin):
self.start_session(httpbin)
# https://github.com/jakubroztocil/httpie/issues/180
# https://github.com/jkbrzt/httpie/issues/180
r1 = http('--session=test',
httpbin.url + '/headers', 'User-Agent:custom',
env=self.env())

View File

@ -30,7 +30,7 @@ class TestMultipartFormDataFileUpload:
'test-file@%s' % FILE_PATH_ARG)
assert HTTP_OK in r
assert r.count('Content-Disposition: form-data; name="test-file";'
' filename="%s"' % os.path.basename(FILE_PATH)) == 2
' filename="%s"' % os.path.basename(FILE_PATH)) == 2
# Should be 4, but is 3 because httpbin
# doesn't seem to support filed field lists
assert r.count(FILE_CONTENT) in [3, 4]

View File

@ -12,10 +12,7 @@ envlist = py26, py27, py34, pypy
[testenv]
deps =
pytest
pytest-httpbin
pytest-httpbin>=0.0.6
commands =
py.test --verbose --doctest-modules --basetemp={envtmpdir} {posargs:./tests ./httpie}
[pytest]
addopts = --tb=native