1
0
mirror of https://github.com/httpie/cli.git synced 2025-06-08 23:46:33 +02:00
This commit is contained in:
Jakub Roztocil 2013-04-11 04:00:41 -03:00
parent e53dcba03e
commit 7ccdece39f
3 changed files with 16 additions and 14 deletions

View File

@ -142,7 +142,9 @@ See the request that is being sent using one of the `output options`_:
$ http -v example.org $ http -v example.org
Use `Github API`_ to post a comment on an issue with `authentication`_: Use `Github API`_ to post a comment on an
`issue <https://github.com/jkbr/httpie/issues/83>`_
with `authentication`_:
.. code-block:: bash .. code-block:: bash
@ -256,8 +258,8 @@ their type is distinguished only by the separator used:
| | The ``==`` separator is used | | | The ``==`` separator is used |
+-----------------------+-----------------------------------------------------+ +-----------------------+-----------------------------------------------------+
| Data Fields | Request data fields to be serialized as a JSON | | Data Fields | Request data fields to be serialized as a JSON |
| ``field=value`` | object (default), or to be form encoded (``--form`` | | ``field=value`` | object (default), or to be form encoded |
| | / ``-f``). | | | (``--form, -f``). |
+-----------------------+-----------------------------------------------------+ +-----------------------+-----------------------------------------------------+
| Raw JSON fields | Useful when sending JSON and one or | | Raw JSON fields | Useful when sending JSON and one or |
| ``field:=json`` | more fields need to be a ``Boolean``, ``Number``, | | ``field:=json`` | more fields need to be a ``Boolean``, ``Number``, |
@ -265,7 +267,7 @@ their type is distinguished only by the separator used:
| | ``meals:='["ham","spam"]'`` or ``pies:=[1,2,3]`` | | | ``meals:='["ham","spam"]'`` or ``pies:=[1,2,3]`` |
| | (note the quotes). | | | (note the quotes). |
+-----------------------+-----------------------------------------------------+ +-----------------------+-----------------------------------------------------+
| Files | Only available with ``-f`` / ``--form``. | | Files | Only available with ``--form, -f``. |
| ``field@/dir/file`` | For example ``screenshot@~/Pictures/img.png``. | | ``field@/dir/file`` | For example ``screenshot@~/Pictures/img.png``. |
| | The presence of a file field results | | | The presence of a file field results |
| | in a ``multipart/form-data`` request. | | | in a ``multipart/form-data`` request. |
@ -296,7 +298,7 @@ both of which can be overwritten:
``Accept`` ``application/json`` ``Accept`` ``application/json``
================ ======================================= ================ =======================================
You can use ``--json`` / ``-j`` to explicitly set ``Accept`` You can use ``--json, -j`` to explicitly set ``Accept``
to ``application/json`` regardless of whether you are sending data to ``application/json`` regardless of whether you are sending data
(it's a shortcut for setting the header via the usual header notation – (it's a shortcut for setting the header via the usual header notation –
``http url Accept:application/json``). ``http url Accept:application/json``).
@ -314,7 +316,6 @@ Simple example:
Accept-Encoding: identity, deflate, compress, gzip Accept-Encoding: identity, deflate, compress, gzip
Content-Type: application/json; charset=utf-8 Content-Type: application/json; charset=utf-8
Host: example.org Host: example.org
User-Agent: HTTPie/0.2.7dev
{ {
"name": "John", "name": "John",
@ -336,7 +337,6 @@ into the resulting object:
Accept: application/json Accept: application/json
Content-Type: application/json; charset=utf-8 Content-Type: application/json; charset=utf-8
Host: api.example.com Host: api.example.com
User-Agent: HTTPie/0.2.7dev
{ {
"age": 29, "age": 29,
@ -361,7 +361,7 @@ Forms
===== =====
Submitting forms is very similar to sending `JSON`_ requests. Often the only Submitting forms is very similar to sending `JSON`_ requests. Often the only
difference is in adding the ``--form`` / ``-f`` option, which ensures that difference is in adding the ``--form, -f`` option, which ensures that
data fields are serialized as, and ``Content-Type`` is set to, data fields are serialized as, and ``Content-Type`` is set to,
``application/x-www-form-urlencoded; charset=utf-8``. ``application/x-www-form-urlencoded; charset=utf-8``.
@ -381,7 +381,6 @@ Regular Forms
.. code-block:: http .. code-block:: http
POST /person/1 HTTP/1.1 POST /person/1 HTTP/1.1
User-Agent: HTTPie/0.2.7dev
Content-Type: application/x-www-form-urlencoded; charset=utf-8 Content-Type: application/x-www-form-urlencoded; charset=utf-8
name=John+Smith&email=john%40example.org name=John+Smith&email=john%40example.org
@ -498,11 +497,12 @@ With password prompt:
Proxies Proxies
======= =======
You can specify proxies to be used through the ``--proxy`` argument: You can specify proxies to be used through the ``--proxy`` argument for each
protocol (which is included in the value in case of redirects across protocols):
.. code-block:: bash .. code-block:: bash
$ http --proxy=http:10.10.1.10:3128 --https:10.10.1.10:1080 example.org $ http --proxy=http:10.10.1.10:3128 --proxy=https:10.10.1.10:1080 example.org
With Basic authentication: With Basic authentication:
@ -581,7 +581,7 @@ documentation examples:
} }
All the other options are just a shortcut for ``--print`` / ``-p``. All the other options are just a shortcut for ``--print, -p``.
It accepts a string of characters each of which represents a specific part of It accepts a string of characters each of which represents a specific part of
the HTTP exchange: the HTTP exchange:
@ -1123,7 +1123,7 @@ Changelog
``--ugly`` has bee removed in favor of ``--pretty=none``. ``--ugly`` has bee removed in favor of ``--pretty=none``.
* `0.2.7`_ (2012-08-07) * `0.2.7`_ (2012-08-07)
* Compatibility with Requests 0.13.6. * Compatibility with Requests 0.13.6.
* Streamed terminal output. ``--stream`` / ``-S`` can be used to enable * Streamed terminal output. ``--stream, -S`` can be used to enable
streaming also with ``--pretty`` and to ensure a more frequent output streaming also with ``--pretty`` and to ensure a more frequent output
flushing. flushing.
* Support for efficient large file downloads. * Support for efficient large file downloads.

View File

@ -15,6 +15,7 @@ from .models import HTTPResponse
from .utils import humanize_bytes from .utils import humanize_bytes
from .compat import urlsplit from .compat import urlsplit
PARTIAL_CONTENT = 206 PARTIAL_CONTENT = 206
@ -71,7 +72,7 @@ def _parse_content_range(content_range, resumed_from):
# Not what we asked for. # Not what we asked for.
raise ContentRangeError( raise ContentRangeError(
'Unexpected Content-Range returned (%r)' 'Unexpected Content-Range returned (%r)'
' for the requested Range ("bytes=%d")' ' for the requested Range ("bytes=%d-")'
% (content_range, resumed_from) % (content_range, resumed_from)
) )

View File

@ -64,6 +64,7 @@ from httpie.input import ParseError
from httpie.compat import is_windows, is_py26, bytes, str from httpie.compat import is_windows, is_py26, bytes, str
from httpie.downloads import _parse_content_range, ContentRangeError from httpie.downloads import _parse_content_range, ContentRangeError
CRLF = '\r\n' CRLF = '\r\n'
HTTPBIN_URL = os.environ.get('HTTPBIN_URL', HTTPBIN_URL = os.environ.get('HTTPBIN_URL',
'http://httpbin.org').rstrip('/') 'http://httpbin.org').rstrip('/')