Skip to main content

A dummy http server that prints requests and responds

Project description

HTTPDummy

                                    __________________
                                   /        ________  \
                                  /   _____|       |___\
                                 |   /  __         __   |
                                /|  |  /o \   _   /o \  |  
                               | | /           \        |
                                \|/   __           __   |
                                  \    |\_________/|   /   
                                   \___|___________|__/                  
                                        |         |
                                       /\_________/\
    _   _ _____ _____ ____  ____     _/     \ /     \_
   | | | |_   _|_   _|  _ \|  _ \ _ | _ _ __ V__  _ __|___  _   _
   | |_| | | |   | | | |_) | | | | | | | '_ ` _ \| '_ ` _ \| | | |
   |  _  | | |   | | |  __/| |_| | |_| | | | | | | | | | | | |_| |
   |_| |_| |_|   |_| |_|   |____/ \__,_|_| |_| |_|_| |_| |_|\__, |
                                                            |___/

HTTPDummy is a development HTTP server tool that prints information about the requests it receives to stdout.

Installation

With PIP:

pip install httpdummy

With Docker:

docker pull ksofa2/httpdummy

Usage

usage: httpdummy [-h] [-H [HEADERS]] [-B [BODY]] [-a ADDRESS] [-p PORT]
                 [-r [RESPONSE_FILE]]

A dummy http server that prints requests and responds

optional arguments:
  -h, --help            show this help message and exit
  -H [HEADERS], --headers [HEADERS]
  -B [BODY], --body [BODY]
  -a ADDRESS, --address ADDRESS
  -p PORT, --port PORT
  -r [RESPONSE_FILE], --response-file [RESPONSE_FILE]
  • Add the -H flag to print request headers.
  • Add the -B flag to print request body.

Use the --response-file to specify a YAML file to set up custom responses for arbitrary method / path combinations. For example, this command...

httpdummy --response-file ~/repsonses.yaml

... with ~/responses.yaml contents ...

---
responses:
  GET /api/foo:
    status: 200
    headers:
      Foo: bar
      Sna: fu
    body: |+
      Hi there!

      How are you?

  POST /api/foo:
    status: 201
    headers:
      Content-type: application/json
    body: |+
      {"answer": 42}

... will make HTTPDummy respond to POST requests to /api/foo with the 201 status code, and the configured headers and body.

NOTE: When started with a response file, HTTPDummy will listen for changes to that file and restart when a change is detected to reload the response definitions.

Environment Variables

These environmental variables will be used as values for their corresponding command-line options. If the command-line option is used, that value will override the one set in the environment.

  • HTTPDUMMY_ADDRESS
  • HTTPDUMMY_PORT
  • HTTPDUMMY_HEADERS
  • HTTPDUMMY_BODY
  • HTTPDUMMY_RESPONSE_FILE

Docker

An image for HTTPDummy is available on DockerHub: https://hub.docker.com/r/ksofa2/httpdummy

docker run -it -p 127.0.0.1:5000:5000 ksofa2/httpdummy

NOTE: The HTTPDUMMY_HEADERS and HTTPDUMMY_BODY are turned on by default in the Docker image.

An example docker-compose.yaml file:

---
version: '3'

services:
  httpdummy:
    image: ksofa2/httpdummy
    environment:
      - HTTPDUMMY_RESPONSE_FILE=/srv/responses.yaml
    ports:
      - 127.0.0.1:5000:5000
    volumes:
      - .:/srv

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

httpdummy-1.1.7.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

httpdummy-1.1.7-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file httpdummy-1.1.7.tar.gz.

File metadata

  • Download URL: httpdummy-1.1.7.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for httpdummy-1.1.7.tar.gz
Algorithm Hash digest
SHA256 6d79d0bbe8895907b21e0321ca409ec2165b7866882889a895d40558ba49df07
MD5 1950456f60b9ff6957c9f36158b3cdea
BLAKE2b-256 9562b7bd795144eff4731d5d9108f95c697788b1e55e1bfb6ed1f14537b71219

See more details on using hashes here.

File details

Details for the file httpdummy-1.1.7-py3-none-any.whl.

File metadata

  • Download URL: httpdummy-1.1.7-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for httpdummy-1.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c60947e069757e3312cea923a8355f716966f0d4be6f9d91f99f9b8dacb0cada
MD5 2bf67af077508254078cae6d18aaa947
BLAKE2b-256 b69333d292b334c8e72fd5e74ed1d39b480122c9f1ac5edb0942a2cbf8cacb33

See more details on using hashes here.

Supported by

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