Requests Guard
===============================
.. image:: https://img.shields.io/travis/skorokithakis/requests-guard.svg
:target: https://travis-ci.org/skorokithakis/requests-guard
.. image:: https://img.shields.io/pypi/v/requests-guard.svg
:target: https://pypi.python.org/pypi/requests-guard
.. image:: https://readthedocs.org/projects/requests-guard/badge/?version=latest
:target: https://readthedocs.org/projects/requests-guard/?badge=latest
:alt: Documentation Status
requests-guard is a small library that allows you to impose size and time limits on your HTTP requests.
* Free software: BSD license
* Documentation: https://requests-guard.readthedocs.org.
Features
--------
* Timeout limits
* Size limits
* Much more!
Installation
------------
Just use `pip` to install it:
```
pip install requests-guard
```
and you're done.
Usage
-----
```
import requests
from requests_guard import guard
r = requests.get("https://www.google.com/", stream=True, timeout=30)
content = guard(r, max_size=3000, timeout=10)
```
`requests-guard` will raise a `ValueError` if it receives more than `max_size` data in total, or if the *entire*
request takes more than `timeout` seconds to be completed. That means that the call will always return after (roughly,
see below for details) `timeout` seconds.
*Note:* You *must* call requests in the manner above, with `stream=True` and `timeout`. `stream=True` allows the size
and time limits to be set, and the `timeout` parameter to `requests` instructs it to close the connection if no data
has been received for that number of seconds.
*Note:* `requests-guard` works by looking at the data as it receives it, so the `timeout` parameter to `requests-guard`
will apply to the *entire* connection, not just the latest chunk. The `timeout` parameter to `requests` means "quit if
we haven't received any data for that long", which means that a response may take an arbitrary amount of time, as long
as it always returns *something* every `timeout` seconds. This means that a request may potentially take up to the sum
of the timeout specified to `requests` and to `requests-guard`, if the server stops replying completely just before
the timeout in `requests-guard` elapses.
History
-------
0.1.0 (2015-03-04)
---------------------
* First release on PyPI.
Metadata
Release files for requests-guard 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| requests-guard-0.1.0.tar.gz | 5.5 kB | Without provenance | Details for requests-guard-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| requests_guard-0.1.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for requests_guard-0.1.0-py2.py3-none-any.whl |
Total release size: 10.5 kB
Release files / requests-guard-0.1.0.tar.gz
| Download URL | requests-guard-0.1.0.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1076f985a68e918aae9e438848297ed959a825f23a29f5f7a05b5b58afee13be
|
|
BLAKE2b-256 checksum How to use checksums |
9a88b4ea639af03416659dc340c813cd204bcd608e94b0bf7a2c750499c9c60f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / requests_guard-0.1.0-py2.py3-none-any.whl
| Download URL | requests_guard-0.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
ab2854402af57bf7a116c610e0facce56a67828224e955426bae8e7b5c400171
|
|
BLAKE2b-256 checksum How to use checksums |
74152a097a38e8c61bcce777649fd289ade8f07ef6749777369fd620a3c1f09b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for requests-guard 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.