Skip to main content

Seekable HTTP responses using 'Range' headers for python-requests

Project description

requests-seekable

Open HTTP responses as seekable file objects. When seek() is called, a new request is made with the Range header set.

This is useful for extracting files from large web-based .zip archives.

Usage

If your existing code looks like this:

import requests

response = requests.get('https://example.com', stream=True)
fileobj = response.raw  # not seekable :(

Then replace response.raw with SeekableResponse(response):

import requests
import requests_seekable

response = requests.get('https://example.com', stream=True)
fileobj = requests_seekable.SeekableResponse(response)  # seekable :)

If the server doesn't support Range headers, then SeekableResponse initializer raises a SeekError exception. This type of exception (a subclass of OSError) is also raised from SeekableResponse.seek() in the following cases:

  • If the given whence value isn't SEEK_SET (0), SEEK_CUR (1) or SEEK_END (2); or
  • If the given whence value is SEEK_END but the content length isn't known; or
  • If the response status isn't 206 "Partial Content" or 416 "Range Not Satisfiable".

Project details


Download files

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

Source Distribution

requests_seekable-0.1.0.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

requests_seekable-0.1.0-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file requests_seekable-0.1.0.tar.gz.

File metadata

  • Download URL: requests_seekable-0.1.0.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for requests_seekable-0.1.0.tar.gz
Algorithm Hash digest
SHA256 80937c40efd440ba0a0b19a6036c7ca3a42e2021c849eff6cdf3519520844aa1
MD5 0104432fc49817429ce11b10a3d57183
BLAKE2b-256 e64788192b4bb3307f6d63330e150a5f463eb086cdbf8a67be9945cac228dba0

See more details on using hashes here.

Provenance

The following attestation bundles were made for requests_seekable-0.1.0.tar.gz:

Publisher: build.yaml on barneygale/requests-seekable

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file requests_seekable-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for requests_seekable-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd60e5567367a38437cbb91da4dd87e9aae0095ea07af8a6ffd4462750bc8434
MD5 e30fa45aa84e76393dddb4802f549804
BLAKE2b-256 d55b202f3d3ab8c7a37d1354841baaaf6d68c8b6517a51dc1d6c8d484b76b9db

See more details on using hashes here.

Provenance

The following attestation bundles were made for requests_seekable-0.1.0-py3-none-any.whl:

Publisher: build.yaml on barneygale/requests-seekable

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page