1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
|
Metadata-Version: 1.1
Name: aiohttp
Version: 1.2.0
Summary: http client/server for asyncio
Home-page: https://github.com/KeepSafe/aiohttp/
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache 2
Description: http client/server for asyncio
==============================
.. image:: https://raw.github.com/KeepSafe/aiohttp/master/docs/_static/aiohttp-icon-128x128.png
:height: 64px
:width: 64px
:alt: aiohttp logo
.. image:: https://travis-ci.org/KeepSafe/aiohttp.svg?branch=master
:target: https://travis-ci.org/KeepSafe/aiohttp
:align: right
.. image:: https://codecov.io/gh/KeepSafe/aiohttp/branch/master/graph/badge.svg
:target: https://codecov.io/gh/KeepSafe/aiohttp
.. image:: https://badge.fury.io/py/aiohttp.svg
:target: https://badge.fury.io/py/aiohttp
Features
--------
- Supports both client and server side of HTTP protocol.
- Supports both client and server Web-Sockets out-of-the-box.
- Web-server has middlewares and pluggable routing.
Getting started
---------------
Client
^^^^^^
To retrieve something from the web:
.. code-block:: python
import aiohttp
import asyncio
async def fetch(session, url):
with aiohttp.Timeout(10, loop=session.loop):
async with session.get(url) as response:
return await response.text()
async def main(loop):
async with aiohttp.ClientSession(loop=loop) as session:
html = await fetch(session, 'http://python.org')
print(html)
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main(loop))
Server
^^^^^^
This is simple usage example:
.. code-block:: python
from aiohttp import web
async def handle(request):
name = request.match_info.get('name', "Anonymous")
text = "Hello, " + name
return web.Response(text=text)
async def wshandler(request):
ws = web.WebSocketResponse()
await ws.prepare(request)
async for msg in ws:
if msg.type == web.MsgType.text:
ws.send_str("Hello, {}".format(msg.data))
elif msg.type == web.MsgType.binary:
ws.send_bytes(msg.data)
elif msg.type == web.MsgType.close:
break
return ws
app = web.Application()
app.router.add_get('/echo', wshandler)
app.router.add_get('/', handle)
app.router.add_get('/{name}', handle)
web.run_app(app)
Note: examples are written for Python 3.5+ and utilize PEP-492 aka
async/await. If you are using Python 3.4 please replace ``await`` with
``yield from`` and ``async def`` with ``@coroutine`` e.g.::
async def coro(...):
ret = await f()
should be replaced by::
@asyncio.coroutine
def coro(...):
ret = yield from f()
Documentation
-------------
https://aiohttp.readthedocs.io/
Discussion list
---------------
*aio-libs* google group: https://groups.google.com/forum/#!forum/aio-libs
Requirements
------------
- Python >= 3.4.2
- async-timeout_
- chardet_
- multidict_
- yarl_
Optionally you may install the cChardet_ and aiodns_ libraries (highly
recommended for sake of speed).
.. _chardet: https://pypi.python.org/pypi/chardet
.. _aiodns: https://pypi.python.org/pypi/aiodns
.. _multidict: https://pypi.python.org/pypi/multidict
.. _yarl: https://pypi.python.org/pypi/yarl
.. _async-timeout: https://pypi.python.org/pypi/async_timeout
.. _cChardet: https://pypi.python.org/pypi/cchardet
License
-------
``aiohttp`` is offered under the Apache 2 license.
Source code
------------
The latest developer version is available in a github repository:
https://github.com/KeepSafe/aiohttp
Benchmarks
----------
If you are interested in by efficiency, AsyncIO community maintains a
list of benchmarks on the official wiki:
https://github.com/python/asyncio/wiki/Benchmarks
CHANGES
=======
1.2.0 (2016-12-17)
------------------
- Extract `BaseRequest` from `web.Request`, introduce `web.Server`
(former `RequestHandlerFactory`), introduce new low-level web server
which is not coupled with `web.Application` and routing #1362
- Make `TestServer.make_url` compatible with `yarl.URL` #1389
- Implement range requests for static files #1382
- Support task attribute for StreamResponse #1410
- Drop `TestClient.app` property, use `TestClient.server.app` instead
(BACKWARD INCOMPATIBLE)
- Drop `TestClient.handler` property, use `TestClient.server.handler` instead
(BACKWARD INCOMPATIBLE)
- `TestClient.server` property returns a test server instance, was
`asyncio.AbstractServer` (BACKWARD INCOMPATIBLE)
- Follow gunicorn's signal semantics in `Gunicorn[UVLoop]WebWorker` #1201
- Call worker_int and worker_abort callbacks in
`Gunicorn[UVLoop]WebWorker` #1202
- Has functional tests for client proxy #1218
- Fix bugs with client proxy target path and proxy host with port #1413
- Fix bugs related to the use of unicode hostnames #1444
- Preserve cookie quoting/escaping #1453
- FileSender will send gzipped response if gzip version available #1426
- Don't override `Content-Length` header in `web.Response` if no body
was set #1400
- Introduce `router.post_init()` for solving #1373
- Fix raise error in case of multiple calls of `TimeServive.stop()`
- Allow to raise web exceptions on router resolving stage #1460
- Add a warning for session creation outside of coroutine #1468
- Avoid a race when application might start accepting incoming requests
but startup signals are not processed yet e98e8c6
- Raise a `RuntimeError` when trying to change the status of the HTTP response
after the headers have been sent #1480
- Fix bug with https proxy acquired cleanup #1340
- Use UTF-8 as the default encoding for multipart text parts #1484
Platform: UNKNOWN
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Development Status :: 5 - Production/Stable
Classifier: Operating System :: POSIX
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Topic :: Internet :: WWW/HTTP
|