Skip to main content

http client/server for asyncio

Project description

http client/server for asyncio

https://secure.travis-ci.org/fafhrd91/aiohttp.png https://coveralls.io/repos/fafhrd91/aiohttp/badge.png?branch=master

Requirements

License

aiohttp is offered under the BSD license.

Getting started

To retrieve something from the web:

mport aiohttp

def get_body(url):
    response = yield from request('GET', url)
    return (yield from response.read())

You can use the get command like this anywhere in your asyncio powered program:

response = yield from aiohttp.request('GET', 'http://python.org')
body = yield from response.read()
print (body)

The signature of request is the following:

request(method, url, *,
        params=None,
        data=None,
        headers=None,
        cookies=None,
        files=None,
        auth=None,
        allow_redirects=True,
        max_redirects=10,
        encoding='utf-8',
        version=(1, 1),
        timeout=None,
        conn_timeout=None,
        compress=None,
        chunked=None,
        expect100=False,
        session=None,
        verify_ssl=True,
        loop=None
)

It constructs and sends a request. It returns response object. Parameters are explained as follow:

  • 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

  • headers: (optional) Dictionary of HTTP Headers to send with the request

  • cookies: (optional) Dict object to send with the request

  • files: (optional) Dictionary of ‘name’: file-like-objects for multipart encoding upload

  • auth: (optional) Auth tuple to enable Basic HTTP Auth

  • timeout: (optional) Float describing the timeout of the request

  • conn_timeout: (optional) Float describing the timeout of the tcp connection

  • allow_redirects: (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.

  • compress: Boolean. Set to True if request has to be compressed with deflate encoding.

  • chunked: Boolean or Integer. Set to chunk size for chunked transfer encoding.

  • expect100: Boolean. Expect 100-continue response from server.

  • session: aiohttp.Session instance to support connection pooling and session cookies.

  • loop: Optional event loop.

CHANGES

0.4.1 (11-12-2013)

  • Added client support for expect: 100-continue header.

0.4 (11-06-2013)

  • Added custom wsgi application close procedure

  • Fixed concurrent host failure in HttpClient

0.3 (11-04-2013)

  • Added PortMapperWorker

  • Added HttpClient

  • Added tcp connection timeout to http client

  • Better client connection errors handling

  • Gracefully handle process exit

0.2

  • Fix packaging

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiohttp-0.4.1.tar.gz (55.3 kB view details)

Uploaded Source

File details

Details for the file aiohttp-0.4.1.tar.gz.

File metadata

  • Download URL: aiohttp-0.4.1.tar.gz
  • Upload date:
  • Size: 55.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aiohttp-0.4.1.tar.gz
Algorithm Hash digest
SHA256 78b68227284374e807abfb71d4339c2017b4e7621212ceced251b4a54f96a5ec
MD5 6d16b3ce81c6962545c61d2ad9155be3
BLAKE2b-256 0ae021ddf7e4dfa248559469c99ce2d4d7c84ef2e718c254e166d42bcb673f8c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page