A command-line interface tool for testing and comparing different HTTP client libraries in Python. Compare the behavior of http.client, requests, and httpx side-by-side.
- Multiple HTTP Clients: Test with
http.client(standard library),requests, andhttpx - All HTTP Methods: Support for GET, POST, PUT, and PATCH
- Batch Testing: Test all clients at once with a single command
- Individual Testing: Test specific clients with specific HTTP methods
- Verbose Mode: Detailed logging for debugging
- Configurable Delays: Prevent rate limiting with adjustable delays between requests
- Clean Architecture: Object-oriented design with abstract base classes
- Type Hints: Full type annotation support for better IDE integration
- Python 3.7+
- Dependencies:
requestshttpx
- Clone the repository:
git clone https://github.com/renanclemonini/http_client_cli_tool.git
cd http_client_cli_tool- Create and activate virtual environment:
Windows:
python -m venv .venv
.venv\Scripts\activateLinux/Mac:
python -m venv .venv
source .venv/bin/activate- Install dependencies:
pip install -r requiments.txtNote: After create virtual environment you can navigate to folder and execute file directly without environment activate
py main.py test-all-post \
--location 'https://api.example.com/endpoint' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer token' \
--data '{"key": "value"}'py main.py test-all-get \
--location 'https://api.github.com/users/github' \
--header 'Accept: application/json'py main.py test-all-put \
--location 'https://api.example.com/users/123' \
--header 'Content-Type: application/json' \
--data '{"name": "Updated Name"}'py main.py http \
--request POST \
--location 'https://api.example.com/endpoint' \
--header 'Content-Type: application/json' \
--data '{"key": "value"}'py main.py requests \
--request GET \
--location 'https://api.example.com/endpoint'py main.py httpx \
--request PUT \
--location 'https://api.example.com/endpoint' \
--data '{"key": "value"}'py main.py httpx2 \
--request POST \
--location 'https://self-signed-cert.example.com/endpoint' \
--data '{"key": "value"}'| Option | Alias | Description | Default |
|---|---|---|---|
--location |
-L |
Request URL (required) | - |
--request |
-X |
HTTP method (GET, POST, PUT, PATCH) | - |
--header |
-H |
Header in format "Key: Value" (repeatable) | - |
--data |
-d |
JSON data to send | - |
--verbose |
-v |
Show detailed request information | false |
--delay |
- | Delay in seconds between requests | 2.0 |
py main.py test-all-post \
--location 'https://doc-validation.fashiongirl.com.br/validar_cnpj_cpf' \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: your-api-key' \
--data '{"documento": "52781445000150"}'py main.py test-all-get \
--verbose \
--location 'https://api.github.com/repos/python/cpython'py main.py requests \
--request GET \
--location 'https://api.example.com/endpoint' \
--delay 5.0http-client-cli/
βββ http_clients.py # HTTP client implementations
β βββ HTTPClient # Abstract base class
β βββ HttpClientLib # http.client implementation
β βββ RequestsClient # requests implementation
β βββ HttpxClient # httpx implementation
β βββ HTTPTester # Testing orchestrator
βββ main.py # CLI entry point
βββ README.md # This file
βββ .venv/ # Virtual environment
HTTPClient (ABC)
βββ HttpClientLib
βββ RequestsClient
βββ HttpxClient
HTTPTester
βββ test_single_client()
βββ test_all_clients()
βββ test_all_post()
βββ test_all_get()
βββ test_all_put()
βββ print_summary()
- HTTPClient: Abstract base class defining the interface for all HTTP clients
- HttpClientLib: Implementation using Python's standard library
http.client - RequestsClient: Implementation using the popular
requestslibrary - HttpxClient: Implementation using the modern
httpxlibrary - HTTPTester: Orchestrates testing across multiple clients with timing and reporting
π§ͺ Testing all clients with POST method...
======================================================================
======================================================================
π Client: http.client
======================================================================
β
Success with http.client!
{
"status": "success",
"message": "Request completed successfully"
}
β³ Waiting 2.0 seconds before next request...
======================================================================
π Client: requests
======================================================================
β Failed with requests
Error: Connection aborted
======================================================================
π Client: httpx
======================================================================
β
Success with httpx!
{
"status": "success",
"message": "Request completed successfully"
}
======================================================================
π TEST SUMMARY
======================================================================
β
Success - http.client
β Failed - requests
β
Success - httpx
π Success rate: 2/3
If you encounter SSL errors with requests or httpx but http.client works:
- The server may have a self-signed certificate
- The server may use an old TLS version
- Try using
httpx2(no SSL verification):
py main.py httpx2 --request POST --location 'https://...' --data '{...}'This intermittent error can occur due to:
- Rate limiting on the server
- Keep-alive connection issues
- Server load
Solutions:
- Increase delay between requests:
--delay 5.0 - Use
http.clientwhich has simpler connection handling - Test individual clients instead of all at once
If testing all clients triggers rate limits:
# Increase delay to 5 seconds
py main.py test-all-post --delay 5.0 --location '...' --data '{...}'Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built to debug and compare SSL/TLS behavior across different HTTP client libraries
- Inspired by real-world API integration challenges
- Special thanks to the maintainers of
requestsandhttpx
Renan Clemonini - +55 71 996 333 313
Project Link: https://github.com/renanclemonini/http_client_cli_tool
β If this project helped you, please consider giving it a star!