Skip to content

Python library for reading HTTP resources as random-access file-like objects using the `Range` header

License

Notifications You must be signed in to change notification settings

barneygale/httpio

Repository files navigation

httpio

HTTP resources as random-access file-like objects

httpio is a small Python library that allows you to access files served over HTTP asfile-likeobjects (which is to say that they support the interface of the standard library'sBufferedIOBase class). It differs from libraries likeurllibandrequestsin that it supportsseek()(which moves an internal pointer), and thatread()makes a request with theRangeheader set. It also supports caching of contents using a configurable block size, and will reuse TCP connections where possible.

Installation

Usepipto install httpio:

$pip install httpio

Usage

importzipfile
importhttpio

url="http://some/large/file.zip"
withhttpio.open(url)asfp:
zf=zipfile.ZipFile(fp)
print(zf.namelist())

Unit Tests

Unit tests are provided for the standard behaviours implemented by the library. They can be run with

$Python -m unittest discover -s tests

or atox.inifile is provided which allows the tests to be run in virtual environments using thetoxtool:

$tox

About

Python library for reading HTTP resources as random-access file-like objects using the `Range` header

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages