Http Utils
A simple requests session wrapper.
Installation
pip install pip install git+git://github.com/juntossomosmais/http-utils.git
Configuration process
If needed you can provide some settings as environment variables.
HTTP_RETRIES=3
HTTP_BACKOFF_FACTOR=0.1
HTTP_STATUS_FORCELIST=
HTTP_TIMEOUT=30
Usage
The basic usage is to call the request_session as a context manager.
from http_utils.session import request_session
def awesome_request():
with request_session() as request:
response = request.get(url="https://www.some-awesome-service.com")
return response
This will add:
- A retry mechanism of 3 attempts for status codes
(defined in the
HTTP_RETRIESvariable or as thetotalparameter) - A backoff factor for each retry in seconds
(defined in the
HTTP_BACKOFF_FACTORvariable or as thebackoff_factorparameter) - A list of status to force retries
(defined in the
HTTP_STATUS_FORCELISTvariable or as thestatus_forcelistparameter) - A list of allowed methods to request
(Defined as ["HEAD", "GET", "PUT", "DELETE", "OPTIONS", "TRACE"] methods by default or as the
allowed_methodsparameter) - A list of hooks
(The default hooks used are the
raise_for_statusand a DEBUG level log for the response body, header and status code)
Helpers
There are also some helper functions that can be used to parse the response object
-
get_response_body: Attemps to return a parsed json response body, returning the response text if it can't.
-
convert_header_to_meta_key: Converts the Django Http Request META header to be separated with a
-instead of_
Tests
In order to execute tests, execute the following:
docker-compose up -d tests
This will run the tests in the python 3.9.4, 3.8.5, 3.7.5, 3.6.9 tox environments
Metadata
Release files for http-utils 0.1.6
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 |
|---|---|---|---|---|
| http_utils-0.1.6.tar.gz | 5.4 kB | Without provenance | Details for http_utils-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| http_utils-0.1.6-py3-none-any.whl | Python 3 | none | any | Details for http_utils-0.1.6-py3-none-any.whl |
Total release size: 11.2 kB
Release files / http_utils-0.1.6.tar.gz
| Download URL | http_utils-0.1.6.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f58d4bf4fd8e7538e9f45ddbc45d865620dd8f1c2577b4f10cc8053f886aa784
|
|
BLAKE2b-256 checksum How to use checksums |
3381b3b6b3f0f082e85a34eac6a092ab528066fd023e4aa7abef9dc4a1b89bb3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.10.19 Linux/6.14.0-1017-azure
|
Release files / http_utils-0.1.6-py3-none-any.whl
| Download URL | http_utils-0.1.6-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0e3334e47f378f5694f1890f3373af827c727b38fb99509a9a20726950c59758
|
|
BLAKE2b-256 checksum How to use checksums |
5a7dca6f250fdb11583be326697c7b1f36d6c3fd8c224824f1a47a0b1df6805f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.10.19 Linux/6.14.0-1017-azure
|
Security for http-utils 0.1.6
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.