Skip to main content

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.

Version Travis CodeCov Docs

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

http://pythonhosted.org/sprockets.mixins.http/

Requirements

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)

Source distribution for sprockets.mixins.http 1.0.4
File Size Uploaded
sprockets.mixins.http-1.0.4.tar.gz 6.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sprockets.mixins.http 1.0.4
File Interpreter ABI Platform
sprockets.mixins.http-1.0.4-py2.py3-none-any.whl Python 2, Python 3 none any Details

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

Release history Release notifications | RSS feed

2.6.0

2 release files

2.5.0

1 release file

2.4.1

2 release files

2.4.0

2 release files

2.3.3

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

1 release file

1.1.1

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

This release

1.0.4 This release

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page