https://github.com/vladmunteanu/th2c
Tornado HTTP/2 Client
https://github.com/vladmunteanu/th2c
async h2 http2 python tornado
Last synced: 5 months ago
JSON representation
Tornado HTTP/2 Client
- Host: GitHub
- URL: https://github.com/vladmunteanu/th2c
- Owner: vladmunteanu
- License: mit
- Created: 2017-10-18T14:01:42.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-08-14T21:46:46.000Z (almost 3 years ago)
- Last Synced: 2025-09-01T15:24:43.114Z (9 months ago)
- Topics: async, h2, http2, python, tornado
- Language: Python
- Homepage:
- Size: 101 KB
- Stars: 78
- Watchers: 8
- Forks: 6
- Open Issues: 4
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
===================
Async HTTP/2 Client
===================
A simple asynchronous HTTP/2 client for Tornado_ applications, based on the awesome h2_ library.
Intended for Python 2 (>= 2.7.9).
This package is in a very early development stage, so expect bugs or changes in the API.
If you spot anything wrong, or would like to suggest improvements, please open an issue or a pull request.
=======
Example
=======
Usage in a coroutine may be:
.. code-block:: python
from th2c import AsyncHTTP2Client
from tornado.httpclient import HTTPRequest
client = AsyncHTTP2Client(
host='nghttp2.org', port=443, secure=True,
)
request = HTTPRequest(
url='https://nghttp2.org/httpbin/get',
method='GET',
)
res = yield client.fetch(request)
====
TODO
====
- moar tests :)
- SERVER_PUSH
- follow_redirects
- priority control
=================
Development setup
=================
If you wish to create a development environment to work on th2c, you can use a Vagrant setup or a virtual environment.
The Vagrant setup is located under vm_, an Ubuntu 16.04 64bit box with Go and Python 2 installed, that maps the project directory under ``/opt/dev/th2c``.
For a minimal set of "integration tests", a Go web server is included in test_server_ that simply echoes back what it receives.
You can run it in debug mode, from the project directory, by executing:
``GODEBUG=http2debug=1 go run test_server/main.go``.
After the server has started, you should run the client by executing:
``python -m th2c``.
Log files should be produced under /opt/dev/th2c/logs.
You can also run unit tests with: ``nosetests tests``
.. _Tornado: http://www.tornadoweb.org/
.. _h2: https://python-hyper.org/h2/
.. _vm: https://github.com/vladmunteanu/th2c/tree/master/vm
.. _test_server: https://github.com/vladmunteanu/th2c/tree/master/test_server