httpdbg: HTTP Debugging Proxy

2.1.6 · active · verified Fri Apr 17

httpdbg is a simple Python tool designed to debug HTTP(S) client and server requests. It functions as a local proxy, capturing and displaying all outgoing and incoming HTTP traffic in a user-friendly web interface. Currently at version 2.1.6, it receives regular updates for bug fixes and minor feature enhancements, maintaining active development.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically start and stop the httpdbg proxy, and then make a simple HTTP request using the `requests` library, ensuring it routes through the proxy for debugging. The environment variables are set to help other libraries (like `httpx`) automatically pick up the proxy.

import requests
from httpdbg import httpdbg
import os

# Start the httpdbg proxy
httpdbg.start()
print(f"httpdbg UI available at: http://127.0.0.1:{httpdbg.port}")

# Configure requests to use the proxy
proxies = {
    'http': f'http://127.0.0.1:{httpdbg.port}',
    'https': f'http://127.0.0.1:{httpdbg.port}'
}
os.environ['HTTP_PROXY'] = proxies['http'] # For clients that respect env vars
os.environ['HTTPS_PROXY'] = proxies['https']

try:
    # Make an HTTP request that will be captured
    print("Making a request...")
    response = requests.get('http://httpbin.org/get', proxies=proxies, timeout=5)
    response.raise_for_status()
    print(f"Request successful: {response.status_code}")
    print("Check the httpdbg UI for captured request details.")
except requests.exceptions.RequestException as e:
    print(f"Request failed: {e}")
finally:
    # Stop the httpdbg proxy
    httpdbg.stop()
    print("httpdbg stopped.")
    # Clean up environment variables
    del os.environ['HTTP_PROXY']
    del os.environ['HTTPS_PROXY']

view raw JSON →