Skip to main content

HTTP request capture and mock library

Project description

HTTP Request Catcher

A Python library for capturing and mocking HTTP requests made with the requests library.

Features

  • Capture all HTTP requests made with the requests library
  • Track request/response headers, bodies, timing, and more
  • Track request source (function name and line number)
  • Support for request mocking
  • Zero configuration required
  • Minimal impact on application performance

Installation

pip install catchttp

Usage

from catchttp import RequestCatcher
import requests

# Initialize the catcher with your explorer service URL
catcher = RequestCatcher("http://localhost:8000")

# Add the decorator to functions that make HTTP requests
@catcher.catch_requests("my_service")
def fetch_data():
    response = requests.get("https://api.example.com/data")
    return response.json()

Explorer Service

The request explorer service (with UI for exploring captured requests) is available as a separate Docker image. You can find it at catchttp-explorer.

Configuration

Request Catcher

  • explorer_url: URL of your explorer service (default: "http://localhost:8000")
  • source_name: Custom name for the request source (optional)

Development

The project structure:

.
├── request_catcher/
│   ├── __init__.py
│   └── decorator.py
├── example.py
├── requirements.txt
└── README.md

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

catchttp-1.0.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

catchttp-1.0.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file catchttp-1.0.0.tar.gz.

File metadata

  • Download URL: catchttp-1.0.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for catchttp-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6033e9ad6038a57f4d3fa09121bfe1a526a871a881f12444459d9a839307a10f
MD5 4a9f1c02d64c6320fbdfeb95a6bec441
BLAKE2b-256 b85378e80e61e4511743f174f00bb8f9d55ab30d80480c9db86cd2f1c385050d

See more details on using hashes here.

File details

Details for the file catchttp-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: catchttp-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for catchttp-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c75b51b419e52c9321d7cbd536cc4b15af83eabb9893d5add75413b16b808a62
MD5 2810f5fe18d7c324c843d9fc33193916
BLAKE2b-256 75b6c9434d3915ce87e3faf9876d46a29f338de9117d9ae07167cc83794a8f60

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page