Metadata-Version: 2.4
Name: requests-seekable
Version: 0.1.0
Summary: Seekable HTTP responses using 'Range' headers for python-requests
Author-email: Barney Gale <barney.gale@gmail.com>
License-Expression: GPL-3.0-or-later
Project-URL: Source code, https://github.com/barneygale/requests-seekable
Project-URL: Issue tracker, https://github.com/barneygale/requests-seekable/issues
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests
Dynamic: license-file

# requests-seekable

Open HTTP responses as *seekable* file objects. When `seek()` is called, a new request is made with
the [`Range`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Range) header set.

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

## Usage

If your existing code looks like this:

```python
import requests

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

Then replace `response.raw` with `SeekableResponse(response)`:

```python
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".
