forked from aio-libs/aiohttp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
--------------------------------- | ||
|
||
|
@@ -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 | ||
|
@@ -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 | ||
-------- | ||
|