Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A tiny, inline-able http module mimicing requests' core API.

Project Description

# Ultralite For when portability is critical, but you still need some HTTP convenience

## Author by Cathal Garvey, copyright 2014, proudly licensed under the [GNU Affero General Public License](

## About Anyone who’s coded in Python for long will have discovered [Kenneth Reitz’s “Requests” library](, which makes HTTP operations far more clean and straightforward than provided for by the Python standard library (though things are improving on that score).

Requests is as simple to install as pip install requests, and as pip comes installed with newer distributions of Python, this is really the best way you can get good HTTP in Python.

However, there are times when you want your code to be portable and not to depend on even the easiest third-party libraries, and for that there’s Ultralite.

The goal is to support 90% of the convenience of requests, while remaining short and in-lineable, so you can literally copy/paste all of the code in this module and drop it into your own code to get a taste of requests, anywhere. And all of this while passing flake8 and pyflakes.

## How do I use this? The intended use-case is to copy/paste this into your own modules or libraries. You can also use pip install ultralight to install for use in the interactive interpreter or to list it as a dependency in

When copy/pasting, just copy the entire Ultralite class from this module, and import the standard library modules it requires. Default headers can be added to the class attribute “_default_headers”; these will be added to all requests’ header dictionaries, with user-provided headers overwriting them.

At present this only supports HEAD and GET requests, but will handle POST/PUT/DELETE in the near future also in a manner similar to requests (enabled by improvements in the standard library).

Features provided that mimic requests:

  • Ultralite methods “get”/”head”/”put”/”post”/”delete” (not all implemented)
  • Methods return Ultralite.UltraliteResponse objects which are requests-like:
    • UltraliteResponse.headers -> dict
    • UltraliteResponse.status_code -> int
    • UltraliteResponse.reason -> str
    • UltraliteResponse.content -> bytes
    • UltraliteResponse.text -> unicode decoding of UltraliteResponse.content
    • UltraliteResponse.raw -> http.client.HTTPResponse / urllib.error.XXX
    • UltraliteResponse.request -> urllib.request.Request
    • UltraliteResponse.raise_for_status() -> Raise Ultralite.UltraliteError if http response code is not within 2XX range, otherwise do nothing.
    • UltraliteResponse.json() -> attempt json-decoding UltraliteResponse.text

## Does this depend on anything? Nope. This is valid pure-stdlib python as of Python 3.3+.

Release History

Release History

This version
History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
ultralite-0.1.1.tar.gz (2.5 kB) Copy SHA256 Checksum SHA256 Source Sep 30, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting