Skip to content

Commit

Permalink
Merge branch 'release/0.6.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth Reitz committed Oct 14, 2011
2 parents 1551158 + 9011852 commit 4f6fc98
Show file tree
Hide file tree
Showing 24 changed files with 378 additions and 252 deletions.
4 changes: 4 additions & 0 deletions AUTHORS
Expand Up @@ -40,3 +40,7 @@ Patches and Suggestions
- Mikko Ohtamaa
- Den Shabalin
- Daniel Miller <danielm@vs-networks.com>
- Alejandro Giacometti
- Rick Mak
- Johan Bergström
- Josselin Jacquard
40 changes: 0 additions & 40 deletions AUTHORS.orig

This file was deleted.

15 changes: 0 additions & 15 deletions HACKING

This file was deleted.

10 changes: 9 additions & 1 deletion HISTORY.rst
@@ -1,12 +1,20 @@
History
-------

0.6.4 (2011-10-13)
++++++++++++++++++

* Automatic decoding of unicode, based on HTTP Headers.
* New ``decode_unicode`` setting
* Removal of ``r.read/close`` methods
* New ``r.faw`` interface for advanced response usage.*
* Automatic expansion of parameterized headers

0.6.3 (2011-10-13)
++++++++++++++++++

* Beautiful ``requests.async`` module, for making async requests w/ gevent.


0.6.2 (2011-10-09)
++++++++++++++++++

Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
@@ -1 +1 @@
include README.rst LICENSE HISTORY.rst
include README.rst LICENSE HISTORY.rst test_requests.py
5 changes: 0 additions & 5 deletions debian/changelog

This file was deleted.

1 change: 0 additions & 1 deletion debian/compat

This file was deleted.

13 changes: 0 additions & 13 deletions debian/control

This file was deleted.

1 change: 0 additions & 1 deletion debian/docs

This file was deleted.

1 change: 0 additions & 1 deletion debian/pyversions

This file was deleted.

42 changes: 0 additions & 42 deletions debian/rules

This file was deleted.

18 changes: 15 additions & 3 deletions docs/api.rst
Expand Up @@ -31,6 +31,21 @@ They all return an instance of the :class:`Response <Response>` object.
.. autoclass:: Response
:inherited-members:

Async
-----

.. module:: requests.async


.. autofunction:: map
.. autofunction:: request
.. autofunction:: head
.. autofunction:: get
.. autofunction:: post
.. autofunction:: put
.. autofunction:: patch
.. autofunction:: delete



Utilities
Expand All @@ -48,9 +63,6 @@ Cookies
.. autofunction:: cookiejar_from_dict
.. autofunction:: add_dict_to_cookiejar

Curl
~~~~
.. autofunction:: curl_from_request

Encodings
~~~~~~~~~
Expand Down
1 change: 1 addition & 0 deletions docs/community/faq.rst
Expand Up @@ -10,6 +10,7 @@ Encoded Data?

Requests automatically decompresses gzip-encoded responses, and does
its best to decodes response content to unicode when possible.
it's best to decodes response content to unicode when possible.

You can get direct access to the raw response (and even the socket),
if needed as well.
Expand Down
2 changes: 1 addition & 1 deletion docs/user/advanced.rst
Expand Up @@ -50,7 +50,7 @@ Requests has first-class support for non-blocking i/o requests, powered
by gevent. This allows you to send a bunch of HTTP requests at the same

First, let's import the async module. Heads up — if you don't have
**gevent** installed, this will fail.::
`gevent <gevent>`_ this will fail::

from requests import async

Expand Down
22 changes: 22 additions & 0 deletions docs/user/install.rst
Expand Up @@ -54,3 +54,25 @@ Once you have a copy of the source, you can embed it in your Python package,
or install it into your site-packages easily::

$ python setup.py install

.. _gevent:

Installing Gevent
-----------------

If you are using the ``requests.async`` module for making concurrent
requests, you need to install gevent.

To install gevent, you'll need ``libevent``.

OSX::

$ brew install libevent

Ubuntu::

$ apt-get install libevent-dev

Once you have ``libevent``, you can install ``gevent`` with ``pip``::

$ pip install gevent
2 changes: 0 additions & 2 deletions docs/user/intro.rst
Expand Up @@ -47,5 +47,3 @@ Requests License

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.



77 changes: 22 additions & 55 deletions requests/api.py
Expand Up @@ -15,7 +15,7 @@
from .models import Request, Response, AuthObject
from .status_codes import codes
from .hooks import dispatch_hook
from .utils import cookiejar_from_dict
from .utils import cookiejar_from_dict, header_expand


__all__ = ('request', 'get', 'head', 'post', 'patch', 'put', 'delete')
Expand All @@ -24,8 +24,8 @@ def request(method, url,
params=None, data=None, headers=None, cookies=None, files=None, auth=None,
timeout=None, allow_redirects=False, proxies=None, hooks=None, return_response=True):

"""Constructs and sends a :class:`Request <models.Request>`.
Returns :class:`Response <models.Response>` object.
"""Constructs and sends a :class:`Request <Request>`.
Returns :class:`Response <Response>` object.
:param method: method for the new :class:`Request` object.
:param url: URL for the new :class:`Request` object.
Expand All @@ -38,13 +38,21 @@ def request(method, url,
:param timeout: (optional) Float describing the timeout of the request.
:param allow_redirects: (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
:param return_response: (optional) If False, an un-sent Request object will returned.
"""

method = str(method).upper()

if cookies is None:
cookies = {}

cookies = cookiejar_from_dict(cookies)

# Expand header values
if headers:
for k, v in headers.items() or {}:
headers[k] = header_expand(v)

args = dict(
method = method,
url = url,
Expand Down Expand Up @@ -89,104 +97,63 @@ def get(url, **kwargs):
"""Sends a GET request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary of parameters, or bytes, to be sent in the query string for the :class:`Request`.
:param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param auth: (optional) AuthObject to enable Basic HTTP Auth.
:param timeout: (optional) Float describing the timeout of the request.
:param allow_redirects: (optional) Boolean. Set to False to disable redirect following.
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
:param **kwargs: Optional arguments that ``request`` takes.
"""


kwargs.setdefault('allow_redirects', True)
return request('GET', url, **kwargs)


def head(url, **kwargs):

"""Sends a HEAD request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary of parameters, or bytes, to be sent in the query string for the :class:`Request`.
:param headers: (optional) Dictionary of HTTP Headers to sent with the :class:`Request`.
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param auth: (optional) AuthObject to enable Basic HTTP Auth.
:param timeout: (optional) Float describing the timeout of the request.
:param allow_redirects: (optional) Boolean. Set to False to disable redirect following.
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
:param **kwargs: Optional arguments that ``request`` takes.
"""

kwargs.setdefault('allow_redirects', True)
return request('HEAD', url, **kwargs)


def post(url, data='', **kwargs):

"""Sends a POST request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary or bytes to send in the body of the :class:`Request`.
:param headers: (optional) Dictionary of HTTP Headers to sent with the :class:`Request`.
:param files: (optional) Dictionary of 'filename': file-like-objects for multipart encoding upload.
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param auth: (optional) AuthObject to enable Basic HTTP Auth.
:param timeout: (optional) Float describing the timeout of the request.
:param allow_redirects: (optional) Boolean. Set to True if redirect following is allowed.
:param params: (optional) Dictionary of parameters, or bytes, to be sent in the query string for the :class:`Request`.
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
:param **kwargs: Optional arguments that ``request`` takes.
"""

return request('POST', url, data=data, **kwargs)
return request('post', url, data=data, **kwargs)


def put(url, data='', **kwargs):
"""Sends a PUT request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary or bytes to send in the body of the :class:`Request`.
:param headers: (optional) Dictionary of HTTP Headers to sent with the :class:`Request`.
:param files: (optional) Dictionary of 'filename': file-like-objects for multipart encoding upload.
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param auth: (optional) AuthObject to enable Basic HTTP Auth.
:param timeout: (optional) Float describing the timeout of the request.
:param allow_redirects: (optional) Boolean. Set to True if redirect following is allowed.
:param params: (optional) Dictionary of parameters, or bytes, to be sent in the query string for the :class:`Request`.
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
:param **kwargs: Optional arguments that ``request`` takes.
"""

return request('PUT', url, data=data, **kwargs)
return request('put', url, data=data, **kwargs)


def patch(url, data='', **kwargs):
"""Sends a PATCH request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary or bytes to send in the body of the :class:`Request`.
:param headers: (optional) Dictionary of HTTP Headers to sent with the :class:`Request`.
:param files: (optional) Dictionary of 'filename': file-like-objects for multipart encoding upload.
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param auth: (optional) AuthObject to enable Basic HTTP Auth.
:param timeout: (optional) Float describing the timeout of the request.
:param allow_redirects: (optional) Boolean. Set to True if redirect following is allowed.
:param params: (optional) Dictionary of parameters, or bytes, to be sent in the query string for the :class:`Request`.
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
:param **kwargs: Optional arguments that ``request`` takes.
"""

return request('PATCH', url, **kwargs)
return request('patch', url, **kwargs)


def delete(url, **kwargs):

"""Sends a DELETE request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary of parameters, or bytes, to be sent in the query string for the :class:`Request`.
:param headers: (optional) Dictionary of HTTP Headers to sent with the :class:`Request`.
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param auth: (optional) AuthObject to enable Basic HTTP Auth.
:param timeout: (optional) Float describing the timeout of the request.
:param allow_redirects: (optional) Boolean. Set to True if redirect following is allowed.
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
:param **kwargs: Optional arguments that ``request`` takes.
"""

return request('DELETE', url, **kwargs)
return request('delete', url, **kwargs)

0 comments on commit 4f6fc98

Please sign in to comment.