Skip to main content
Help us improve Python packaging – donate today!

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.

Gunicorn worker

Paster configuration example:

[server:main]
use = egg:gunicorn#main
host = 0.0.0.0
port = 8080
worker_class = aiohttp.worker.AsyncGunicornWorker

CHANGES

0.4.4 (11-15-2013)

  • Resolve only AF_INET family, because it is not clear how to pass extra info to asyncio.

0.4.3 (11-15-2013)

  • Allow to wait completion of request with HttpResponse.wait_for_close()

0.4.2 (11-14-2013)

  • Handle exception in client request stream.
  • Prevent host resolving for each client request.

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

Release history Release notifications

History Node

3.1.3

History Node

3.1.2

History Node

3.1.1

History Node

3.1.0

History Node

3.0.9

History Node

3.0.8

History Node

3.0.7

History Node

3.0.6

History Node

3.0.5

History Node

3.0.4

History Node

3.0.3

History Node

3.0.2

History Node

3.0.1

History Node

3.0.0

History Node

3.0.0b4

History Node

3.0.0b3

History Node

3.0.0b2

History Node

3.0.0b1

History Node

3.0.0b0

History Node

2.3.10

History Node

2.3.9

History Node

2.3.8

History Node

2.3.7

History Node

2.3.6

History Node

2.3.5

History Node

2.3.4

History Node

2.3.3

History Node

2.3.2

History Node

2.3.2b3

History Node

2.3.2b2

History Node

2.3.1

History Node

2.3.1a1

History Node

2.3.0

History Node

2.3.0a4

History Node

2.3.0a3

History Node

2.3.0a2

History Node

2.3.0a1

History Node

2.2.5

History Node

2.2.4

History Node

2.2.3

History Node

2.2.2

History Node

2.2.1

History Node

2.2.0

History Node

2.1.0

History Node

2.0.7

History Node

2.0.6

History Node

2.0.5

History Node

2.0.4

History Node

2.0.3

History Node

2.0.2

History Node

2.0.1

History Node

2.0.0

History Node

2.0.0rc1

History Node

1.3.5

History Node

1.3.4

History Node

1.3.3

History Node

1.3.2

History Node

1.3.1

History Node

1.3.0

History Node

1.2.0

History Node

1.1.6

History Node

1.1.5

History Node

1.1.4

History Node

1.1.3

History Node

1.1.2

History Node

1.1.1

History Node

1.1.0

History Node

1.0.5

History Node

1.0.3

History Node

1.0.2

History Node

1.0.1

History Node

1.0.0

History Node

0.22.5

History Node

0.22.4

History Node

0.22.3

History Node

0.22.2

History Node

0.22.1

History Node

0.22.0

History Node

0.22.0b6

History Node

0.22.0b5

History Node

0.22.0b4

History Node

0.22.0b3

History Node

0.22.0b2

History Node

0.22.0b1

History Node

0.22.0b0

History Node

0.22.0a0

History Node

0.21.6

History Node

0.21.5

History Node

0.21.4

History Node

0.21.2

History Node

0.21.1

History Node

0.21.0

History Node

0.20.2

History Node

0.20.1

History Node

0.20.0

History Node

0.19.0

History Node

0.18.4

History Node

0.18.3

History Node

0.18.2

History Node

0.18.1

History Node

0.18.0

History Node

0.17.4

History Node

0.17.3

History Node

0.17.2

History Node

0.17.1

History Node

0.17.0

History Node

0.16.6

History Node

0.16.5

History Node

0.16.4

History Node

0.16.3

History Node

0.16.2

History Node

0.16.1

History Node

0.16.0

History Node

0.15.3

History Node

0.15.2

History Node

0.15.1

History Node

0.15.0

History Node

0.14.4

History Node

0.14.3

History Node

0.14.2

History Node

0.14.1

History Node

0.14.0

History Node

0.13.1

History Node

0.13.0

History Node

0.12.0

History Node

0.11.0

History Node

0.10.2

History Node

0.10.1

History Node

0.10.0

History Node

0.9.3

History Node

0.9.2

History Node

0.9.1

History Node

0.9.0

History Node

0.8.4

History Node

0.8.3

History Node

0.8.2

History Node

0.8.1

History Node

0.8.0

History Node

0.7.3

History Node

0.7.2

History Node

0.7.1

History Node

0.7.0

History Node

0.6.5

History Node

0.6.4

History Node

0.6.3

History Node

0.6.2

History Node

0.6.1

History Node

0.6.0

History Node

0.5.0

This version
History Node

0.4.4

History Node

0.4.3

History Node

0.4.2

History Node

0.4.1

History Node

0.4

History Node

0.3

History Node

0.2

History Node

0.1

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
aiohttp-0.4.4.tar.gz (56.9 kB) Copy SHA256 hash SHA256 Source None Nov 15, 2013

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page