sprockets.mixins.http
HTTP Client Mixin for Tornado RequestHandlers. Automatically retries on errors, sleep when rate limited, and handles content encoding and decoding using MsgPack and JSON.
Installation
sprockets.mixins.http is available on the Python Package Index and can be installed via pip or easy_install:
pip install sprockets.mixins.http
If you would like to use tornado.curl_httpclient.CurlAsyncHTTPClient, you can install pycurl with:
pip install sprockets.mixins.http[curl]
Documentation
Requirements
tornado >=4.2.0,<5
Example
This examples demonstrates the most basic usage of sprockets.mixins.http
from tornado import gen, ioloop, web
from sprockets.mixins import http
class RequestHandler(http.HTTPClientMixin, web.RequestHandler):
@gen.coroutine
def get(self, *args, **kwargs):
response = yield self.http_fetch('https://api.github.com')
if not response.ok:
self.set_status(response.code)
self.write(response.body)
self.finish()
if __name__ == "__main__":
app = web.Application([web.url(r'/', RequestHandler)])
app.listen(8000)
ioloop.IOLoop.current().start()
As with Tornado, to use the curl client which has numerous benefits:
from tornado import gen, httpclient, ioloop, web
from sprockets.mixins import http
httpclient.AsyncHTTPClient.configure(
'tornado.curl_httpclient.CurlAsyncHTTPClient')
class RequestHandler(http.HTTPClientMixin, web.RequestHandler):
@gen.coroutine
def get(self, *args, **kwargs):
response = yield self.http_fetch('https://api.github.com')
if not response.ok:
self.set_status(response.code)
self.write(response.body)
self.finish()
if __name__ == "__main__":
app = web.Application([web.url(r'/', RequestHandler)])
app.listen(8000)
ioloop.IOLoop.current().start()
License
sprockets.mixins.http is released under the 3-Clause BSD license.
Metadata
Release files for sprockets.mixins.http 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sprockets.mixins.http-1.0.4.tar.gz | 6.9 kB | Without provenance | Details for sprockets.mixins.http-1.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sprockets.mixins.http-1.0.4-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for sprockets.mixins.http-1.0.4-py2.py3-none-any.whl |
Total release size: 15.9 kB
Release files / sprockets.mixins.http-1.0.4.tar.gz
| Download URL | sprockets.mixins.http-1.0.4.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
466818b49e04e14ad24736a33794625c17c58d03d7a72ed50cc68c872a7254bd
|
|
BLAKE2b-256 checksum How to use checksums |
afa8f746ce8d2501d8ded88f176831728dacf5bb75cacd2ab22f0f46d014253b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / sprockets.mixins.http-1.0.4-py2.py3-none-any.whl
| Download URL | sprockets.mixins.http-1.0.4-py2.py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
f6206ad884a57ee44ff4fe4f8fcee6afd68e64c1d81d3eeeb3407611d9b15280
|
|
BLAKE2b-256 checksum How to use checksums |
28a66cc7c921892e3039422bfc721df7e6cc565f7aa1c17805abe33176e8a04a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for sprockets.mixins.http 1.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.