Metadata-Version: 2.1
Name: aiosonic
Version: 0.9.3b1
Summary: Async http client
Home-page: UNKNOWN
Author: Johanderson Mogollon
Author-email: johanderson@mogollon.com.ve
License: MIT
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Description-Content-Type: text/markdown
Requires-Dist: chardet (==4.0.0)
Requires-Dist: cython (==0.29.21)
Requires-Dist: h2 (==4.0.0)
Requires-Dist: hpack (==4.0.0)
Requires-Dist: hyperframe (==6.0.0)
Provides-Extra: test
Requires-Dist: aiohttp (==3.7.3) ; extra == 'test'
Requires-Dist: asgiref (==3.3.1) ; extra == 'test'
Requires-Dist: async-timeout (==3.0.1) ; extra == 'test'
Requires-Dist: attrs (==20.3.0) ; extra == 'test'
Requires-Dist: certifi (==2020.11.8) ; extra == 'test'
Requires-Dist: chardet (==3.0.4) ; extra == 'test'
Requires-Dist: click (==7.1.2) ; extra == 'test'
Requires-Dist: coverage (==5.3) ; extra == 'test'
Requires-Dist: coveralls (==2.2.0) ; extra == 'test'
Requires-Dist: django (==3.1.3) ; extra == 'test'
Requires-Dist: docopt (==0.6.2) ; extra == 'test'
Requires-Dist: filelock (==3.0.12) ; extra == 'test'
Requires-Dist: h11 (==0.11.0) ; extra == 'test'
Requires-Dist: httpcore (==0.12.2) ; extra == 'test'
Requires-Dist: httpx (==0.16.1) ; extra == 'test'
Requires-Dist: idna (==2.10) ; extra == 'test'
Requires-Dist: importlib-metadata (==2.0.0) ; extra == 'test'
Requires-Dist: iniconfig (==1.1.1) ; extra == 'test'
Requires-Dist: multidict (==5.0.2) ; extra == 'test'
Requires-Dist: mypy-extensions (==0.4.3) ; extra == 'test'
Requires-Dist: mypy (==0.790) ; extra == 'test'
Requires-Dist: packaging (==20.4) ; extra == 'test'
Requires-Dist: pluggy (==0.13.1) ; extra == 'test'
Requires-Dist: py (==1.9.0) ; extra == 'test'
Requires-Dist: pyparsing (==2.4.7) ; extra == 'test'
Requires-Dist: pytest-aiohttp (==0.3.0) ; extra == 'test'
Requires-Dist: pytest-asyncio (==0.14.0) ; extra == 'test'
Requires-Dist: pytest-cov (==2.10.1) ; extra == 'test'
Requires-Dist: pytest-django (==4.1.0) ; extra == 'test'
Requires-Dist: pytest-mock (==3.3.1) ; extra == 'test'
Requires-Dist: pytest-mypy (==0.8.0) ; extra == 'test'
Requires-Dist: pytest-sugar (==0.9.4) ; extra == 'test'
Requires-Dist: pytest-timeout (==1.4.2) ; extra == 'test'
Requires-Dist: pytest (==6.1.2) ; extra == 'test'
Requires-Dist: pytz (==2020.4) ; extra == 'test'
Requires-Dist: requests (==2.25.0) ; extra == 'test'
Requires-Dist: six (==1.15.0) ; extra == 'test'
Requires-Dist: sniffio (==1.2.0) ; extra == 'test'
Requires-Dist: sqlparse (==0.4.1) ; extra == 'test'
Requires-Dist: termcolor (==1.1.0) ; extra == 'test'
Requires-Dist: toml (==0.10.2) ; extra == 'test'
Requires-Dist: typed-ast (==1.4.1) ; extra == 'test'
Requires-Dist: typing-extensions (==3.7.4.3) ; extra == 'test'
Requires-Dist: urllib3 (==1.26.2) ; extra == 'test'
Requires-Dist: uvicorn (==0.12.2) ; extra == 'test'
Requires-Dist: yarl (==1.6.3) ; extra == 'test'
Requires-Dist: zipp (==3.4.0) ; extra == 'test'

[![Build Status](https://travis-ci.org/sonic182/aiosonic.svg?branch=master)](https://travis-ci.org/sonic182/aiosonic)
[![Azure Build Status](https://dev.azure.com/johander-182/aiosonic/_apis/build/status/sonic182.aiosonic?branchName=master)](https://dev.azure.com/johander-182/aiosonic/_build/latest?definitionId=1&branchName=master)
[![Coverage Status](https://coveralls.io/repos/github/sonic182/aiosonic/badge.svg?branch=master)](https://coveralls.io/github/sonic182/aiosonic?branch=master)
[![PyPI version](https://badge.fury.io/py/aiosonic.svg)](https://badge.fury.io/py/aiosonic)
[![Documentation Status](https://readthedocs.org/projects/aiosonic/badge/?version=latest)](https://aiosonic.readthedocs.io/en/latest/?badge=latest)
[![Gitter](https://badges.gitter.im/aiosonic/community.svg)](https://gitter.im/aiosonic/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
# aiosonic - a Python asyncio http client

Very fast Python asyncio http client

Here is some [documentation](https://aiosonic.readthedocs.io/en/latest/).

There is a performance script in tests folder which shows very nice numbers

```
» python tests/performance.py
doing tests...
{
 "aiosonic": "1000 requests in 110.03 ms",
 "aiosonic cyclic": "1000 requests in 332.10 ms",
 "aiohttp": "1000 requests in 427.31 ms",
 "requests": "1000 requests in 4915.04 ms",
 "httpx": "1000 requests in 638.04 ms"
}
aiosonic is 288.36% faster than aiohttp
aiosonic is 4367.04% faster than requests
aiosonic is 201.83% faster than aiosonic cyclic
aiosonic is 479.89% faster than httpx
```

You can perform this test by installing all test dependencies with `pip install -e ".[test]"` and doing `python tests/performance.py` in your own machine

# Requirements:

* Python>=3.6


# Features:

* Keepalive and smart pool of connections
* Multipart File Uploads
* Chunked responses handling
* Chunked requests
* Connection Timeouts
* Automatic Decompression
* Follow Redirects
* Fully type annotated.
* 100% test coverage.

# Installation

`pip install aiosonic`

# Usage

```python
import asyncio
import aiosonic
import json


async def run():
    client = aiosonic.HttpClient()

    # ##################
    # Sample get request
    # ##################
    response = await client.get('https://www.google.com/')
    assert response.status_code == 200
    assert 'Google' in (await response.text())

    # ##################
    # Post data as multipart form
    # ##################
    url = "https://postman-echo.com/post"
    posted_data = {'foo': 'bar'}
    response = await client.post(url, data=posted_data)

    assert response.status_code == 200
    data = json.loads(await response.content())
    assert data['form'] == posted_data

    # ##################
    # Posted as json
    # ##################
    response = await client.post(url, json=posted_data)

    assert response.status_code == 200
    data = json.loads(await response.content())
    assert data['json'] == posted_data

    # ##################
    # Sample request + timeout
    # ##################
    from aiosonic.timeout import Timeouts
    timeouts = Timeouts(
        sock_read=10,
        sock_connect=3
    )
    response = await client.get('https://www.google.com/', timeouts=timeouts)
    assert response.status_code == 200
    assert 'Google' in (await response.text())
    await client.shutdown()

    print('success')


if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(run())
```

# [TODO'S](https://github.com/sonic182/aiosonic/projects/1)

* HTTP2
  * [x] Get
  * [ ] Request with data sending
* Better documentation
* International Domains and URLs (idna + cache)
* Requests using a http proxy
* Basic/Digest Authentication
* [x] Sessions with Cookie Persistence
* [x] Elegant Key/Value Cookies

# Development

Install packages with pip-tools:
```bash
pip install pip-tools
pip-compile
pip-compile test-requirements.in
pip-sync requirements.txt test-requirements.txt
```

# Contribute

1. Fork
2. create a branch `feature/your_feature`
3. commit - push - pull request

Thanks :)

