HTTP Client
A lightweight, chainable HTTP client for Python that supports automatic retries, custom retry callbacks, and easy JSON or form submissions.
Features
- Simple and expressive chainable API
- Built-in retry support with customizable retry callbacks
- Automatic JSON and form data handling
- Fully testable with responses
- No heavy dependencies — designed to be minimal and easy to extend
Usage
- Basic GET request
from event_scale_http_client import Http
response = Http().get("http://127.0.0.1:7000/", {
"name": "Alex"
})
print(response.status_code)
print(response.json())
- Automatic retries with callback
You can define how many times the request should retry and handle each failed attempt with a callback:
from event_scale_http_client import Http
def retry_callback(attempt, error):
print(f"Attempt {attempt} failed due to: {error}")
(
Http()
.retry(3, retry_callback)
.get("http://127.0.0.1:7000/")
)
Explanation:
- retry(3, callback) → retries up to 3 times if the request fails.
- The callback function receives two arguments: attempt → current attempt number (starting at 1) error → the exception or status that caused the failure
- POST request with JSON body
from event_scale_http_client import Http
data = {
"name": "Bedram",
"email": "tmgbedu@gmail.com"
}
response = Http().post("http://127.0.0.1:7000", data)
print(response.status_code)
- Sends JSON data by default (Content-Type: application/json).
- POST request as form data
from event_scale_http_client import Http
(
Http()
.asForm()
.post("http://127.0.0.1:7000", {
"name": "Bedram",
"email": "tmgbedu@gmail.com"
})
)
- Sends data as application/x-www-form-urlencoded.
- Automatically encodes form fields.
Metadata
Release files for event_scale_http_client 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| event_scale_http_client-0.1.1.tar.gz | 2.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| event_scale_http_client-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.1 kB
Release files / event_scale_http_client-0.1.1.tar.gz
| Download URL | event_scale_http_client-0.1.1.tar.gz |
|---|---|
| Size | 2.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
68433f830f5abf8f36f3a9bfb66e6a55b57787dd52d8bbeb0efc45e6b8303e5b
|
|
BLAKE2b-256 checksum How to use checksums |
7536ce582a0b9e4e20624161b2a0360c8f070ffc6b256fff978a41ba659e7df5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.12.8 Darwin/23.5.0
|
Release files / event_scale_http_client-0.1.1-py3-none-any.whl
| Download URL | event_scale_http_client-0.1.1-py3-none-any.whl |
|---|---|
| Size | 3.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
514c1d6b933f1417ac59f1a4a572d2f9724ab40c46ad6d22932aba5fd2c921b0
|
|
BLAKE2b-256 checksum How to use checksums |
a12377c7a24138a8e49f5d23e4a2253643f6d098dbda1eb691323d6e65737807
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.12.8 Darwin/23.5.0
|