From 7ccdece39fc2cbf4459ad1bcca22182b13b0e9e0 Mon Sep 17 00:00:00 2001 From: Jakub Roztocil Date: Thu, 11 Apr 2013 04:00:41 -0300 Subject: [PATCH] Cleanup --- README.rst | 26 +++++++++++++------------- httpie/downloads.py | 3 ++- tests/tests.py | 1 + 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/README.rst b/README.rst index ba659e71..ae4b1dae 100644 --- a/README.rst +++ b/README.rst @@ -142,7 +142,9 @@ See the request that is being sent using one of the `output options`_: $ 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 `_ +with `authentication`_: .. code-block:: bash @@ -256,8 +258,8 @@ their type is distinguished only by the separator 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 (``--form`` | -| | / ``-f``). | +| ``field=value`` | object (default), or to be form encoded | +| | (``--form, -f``). | +-----------------------+-----------------------------------------------------+ | Raw JSON fields | Useful when sending JSON and one or | | ``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]`` | | | (note the quotes). | +-----------------------+-----------------------------------------------------+ -| Files | Only available with ``-f`` / ``--form``. | +| Files | Only available with ``--form, -f``. | | ``field@/dir/file`` | For example ``screenshot@~/Pictures/img.png``. | | | The presence of a file field results | | | in a ``multipart/form-data`` request. | @@ -296,7 +298,7 @@ both of which can be overwritten: ``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 (it's a shortcut for setting the header via the usual header notation – ``http url Accept:application/json``). @@ -314,7 +316,6 @@ Simple example: Accept-Encoding: identity, deflate, compress, gzip Content-Type: application/json; charset=utf-8 Host: example.org - User-Agent: HTTPie/0.2.7dev { "name": "John", @@ -336,7 +337,6 @@ into the resulting object: Accept: application/json Content-Type: application/json; charset=utf-8 Host: api.example.com - User-Agent: HTTPie/0.2.7dev { "age": 29, @@ -361,7 +361,7 @@ Forms ===== 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, ``application/x-www-form-urlencoded; charset=utf-8``. @@ -381,7 +381,6 @@ Regular Forms .. code-block:: http POST /person/1 HTTP/1.1 - User-Agent: HTTPie/0.2.7dev Content-Type: application/x-www-form-urlencoded; charset=utf-8 name=John+Smith&email=john%40example.org @@ -498,11 +497,12 @@ With password prompt: 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 - $ 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: @@ -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 the HTTP exchange: @@ -1123,7 +1123,7 @@ Changelog ``--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 + * 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. diff --git a/httpie/downloads.py b/httpie/downloads.py index 5d6ab50e..a20d7d0e 100644 --- a/httpie/downloads.py +++ b/httpie/downloads.py @@ -15,6 +15,7 @@ from .models import HTTPResponse from .utils import humanize_bytes from .compat import urlsplit + PARTIAL_CONTENT = 206 @@ -71,7 +72,7 @@ def _parse_content_range(content_range, resumed_from): # Not what we asked for. raise ContentRangeError( 'Unexpected Content-Range returned (%r)' - ' for the requested Range ("bytes=%d")' + ' for the requested Range ("bytes=%d-")' % (content_range, resumed_from) ) diff --git a/tests/tests.py b/tests/tests.py index 913d340a..8418f818 100755 --- a/tests/tests.py +++ b/tests/tests.py @@ -64,6 +64,7 @@ from httpie.input import ParseError from httpie.compat import is_windows, is_py26, bytes, str from httpie.downloads import _parse_content_range, ContentRangeError + CRLF = '\r\n' HTTPBIN_URL = os.environ.get('HTTPBIN_URL', 'http://httpbin.org').rstrip('/')