Skip to content

Commit

Permalink
added few lines in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
popravich committed Jul 16, 2014
1 parent ac3bd9c commit f55d0b0
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions docs/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ post requests togethere::
>>> r = yield from aiohttp.request('get', 'http:https://python.org')
>>> yield from aiohttp.request('post', 'http:https://httpbin.org/post', data=r.content)

.. _client-keep-alive:

Keep-Alive and connection pooling
---------------------------------

Expand All @@ -309,18 +311,30 @@ Proxy support

aiohttp supports proxy. You have to use :class:`aiohttp.connector.ProxyConnector`::

>>> conn = aiohttp.ProxyConnector(proxy="http:https://some.proxy.com")
>>> r = yield from aiohttp.request('get', 'http:https://python.org', connector=conn)
>>> conn = aiohttp.ProxyConnector(proxy="http:https://some.proxy.com")
>>> r = yield from aiohttp.request('get', 'http:https://python.org', connector=conn)

``ProxyConnector`` also supports proxy authorization::

>>> conn = aiohttp.ProxyConnector(
... proxy="http:https://some.proxy.com",
... proxy_auth=aiohttp.BasicAuth('user', 'pass'))
>>> r = yield from aiohttp.request('get', 'http:https://python.org', connector=conn)

Auth credentials can be passed in proxy URL::

>>> conn = aiohttp.ProxyConnector(proxy="http:https://user:[email protected]")
>>> r = yield from aiohttp.request('get', 'http:https://python.org', connector=conn)


Response Status Codes
---------------------

We can check the response status code::

>>> r = aiohttp.request('get', 'http:https://httpbin.org/get')
>>> r.status
200
>>> r = aiohttp.request('get', 'http:https://httpbin.org/get')
>>> r.status
200


Response Headers
Expand Down Expand Up @@ -370,6 +384,22 @@ parameter::
>>> r.text
'{"cookies": {"cookies_are": "working"}}'

With :ref:`connection pooling<client-keep-alive>` you can share cookies between
requests::

>>> conn = aiohttp.connector.TCPConnector(share_cookies=True)
>>> r = yield from aiohttp.request('get', 'http:https://httpbin.org/cookies/set?k1=v1',
... connector=conn)
>>> r.text
'{"cookies": {"k1": "v1"}}'
>>> r = yield from aiohttp.request('get', 'http:https://httpbin.org/cookies',
... connection=conn)
>>> r.text
'{"cookies": {"k1": "v1"}}'

.. note::
By default ``share_cookies`` set to ``False``.


Timeouts
--------
Expand Down

0 comments on commit f55d0b0

Please sign in to comment.