client

HTTP Client for asyncio.

Module Contents

Classes

ClientTimeout()
ClientSession(self) First-class interface for making HTTP requests.
_BaseRequestContextManager(self,coro)
_RequestContextManager()
_WSRequestContextManager()
_SessionRequestContextManager(self,coro,session)

Functions

request(method,url) Constructs and sends a request. Returns response object.
class ClientTimeout
class ClientSession

First-class interface for making HTTP requests.

__init__()
__init_subclass__()
__setattr__(name, val)
__del__(_warnings=warnings)
request(method, url, **kwargs)

Perform HTTP request.

_request(method, url)
ws_connect(url)

Initiate websocket connection.

_ws_connect(url)
_prepare_headers(headers)

Add default headers and transform it to CIMultiDict

get(url, **kwargs)

Perform HTTP GET request.

options(url, **kwargs)

Perform HTTP OPTIONS request.

head(url, **kwargs)

Perform HTTP HEAD request.

post(url, **kwargs)

Perform HTTP POST request.

put(url, **kwargs)

Perform HTTP PUT request.

patch(url, **kwargs)

Perform HTTP PATCH request.

delete(url, **kwargs)

Perform HTTP DELETE request.

close()

Close underlying connector.

Release all acquired resources.

closed()

Is client session closed.

A readonly property.

connector()

Connector instance used for the session.

cookie_jar()

The session cookies.

version()

The session HTTP protocol version.

loop()

Session’s loop.

detach()

Detach connector from session without closing the former.

Session is switched to closed state anyway.

__enter__()
__exit__(exc_type, exc_val, exc_tb)
__aenter__()
__aexit__(exc_type, exc_val, exc_tb)
class _BaseRequestContextManager(coro)
__init__(coro)
send(arg)
throw(arg)
close()
__await__()
__iter__()
__aenter__()
class _RequestContextManager
__aexit__(exc_type, exc, tb)
class _WSRequestContextManager
__aexit__(exc_type, exc, tb)
class _SessionRequestContextManager(coro, session)
__init__(coro, session)
__aenter__()
__aexit__(exc_type, exc_val, exc_tb)
request(method, url)

Constructs and sends a request. Returns response object. method - HTTP method url - request url params - (optional) Dictionary or bytes to be sent in the query

string of the new request
data - (optional) Dictionary, bytes, or file-like object to
send in the body of the request

json - (optional) Any json compatibile python object headers - (optional) Dictionary of HTTP Headers to send with

the request

cookies - (optional) Dict object to send with the request auth - (optional) BasicAuth named tuple represent HTTP Basic Auth auth - aiohttp.helpers.BasicAuth allow_redirects - (optional) If set to False, do not follow

redirects

version - Request HTTP version. compress - Set to True if request has to be compressed

with deflate encoding.

chunked - Set to chunk size for chunked transfer encoding. expect100 - Expect 100-continue response from server. connector - BaseConnector sub-class instance to support

connection pooling.
read_until_eof - Read response until eof if response
does not have Content-Length header.

loop - Optional event loop. Usage:

>>> import aiohttp
>>> resp = await aiohttp.request('GET', 'http://python.org/')
>>> resp
<ClientResponse(python.org/) [200]>
>>> data = await resp.read()