Skip to main content

The application starts a Web server which logs details of all incoming HTTP requests.

Project description

docker-image-version license downloads docker-image-size docker-pulls

http-reqtrace

Description

The application starts a Web server which logs details of all incoming HTTP requests such as:

  • HTTP Method & URL
  • Query params
  • Headers
  • Body

The application accepts all HTTP methods and URIs. The routing is defined like this:

  • /status/:statusCode : return an HTTP response with status code statusCode and body {"message":"OK|KO"}
  • /**/* : return an HTTP response with status code 200 OK and body {"message":"OK"}
  • /metrics : return Prometheus metrics regarding HTTP requests

Following query parameters are also supported:

  • ?latencyInMs=60000 : wait for the given period in milliseconds before responding. This time cannot exceed 5 minuts.

This service can be used to :

  • See very quickly what are the requests received and inspect their content.
  • Have a quick way to simulate specific cases with particular HTTP response codes.

How to use

Starts the service

  • Run container as root:
$ docker run -ti --name http-reqtrace -p 80:80 julb/http-reqtrace:latest
  • Run container as non-root:
$ docker run -ti --name http-reqtrace -p 80:8080 -e PORT=8080 -u 65534:65534 julb/http-reqtrace:latest

Note: the PORT environment variable can be set to customize listening port.

Request the service with any method, URI and parameters

$ curl http://localhost/context/uri?param1=value1&param2=value2 -H "Authorization: Bearer jwt"
{"statusCode": 200,"message":"OK"}
INFO in app: > [GET] HTTP/1.1 http://localhost/context/uri?param1=value1&param2=value2
INFO in app: >>     Header : Host : localhost
INFO in app: >>     Header : User-Agent : curl/7.54.0
INFO in app: >>     Header : Accept : */*
INFO in app: >>     Header : Authorization : Bearer jwt
INFO in app: >>     Query  : param1 : value1
INFO in app: >>     Query  : param2 : value2
INFO in app: >>     Body   : b''
INFO in app: < [ HTTP 200 ]

Getting specific HTTP responses status codes

$ curl http://localhost/status/404 -H "Authorization: Bearer jwt"
{"statusCode":404,"message":"KO"}

$ curl http://localhost/status/500 -H "Authorization: Bearer jwt"
{"statusCode":500,"message":"KO"}
INFO in app: > [GET] HTTP/1.1 http://localhost/status/404
INFO in app: >>     Header : Host : localhost
INFO in app: >>     Header : User-Agent : curl/7.54.0
INFO in app: >>     Header : Accept : */*
INFO in app: >>     Header : Authorization : Bearer jwt
INFO in app: >>     Body   : b''
INFO in app: < [ HTTP 404 ]
INFO in app: > [GET] HTTP/1.1 http://localhost/status/500
INFO in app: >>     Header : Host : localhost
INFO in app: >>     Header : User-Agent : curl/7.54.0
INFO in app: >>     Header : Accept : */*
INFO in app: >>     Header : Authorization : Bearer jwt
INFO in app: >>     Body   : b''
INFO in app: < [ HTTP 500 ]

Simulate latency

$ curl http://localhost/status/504?latencyInMs=60000
{"statusCode":504,"message":"KO"}
INFO in app: > [GET] HTTP/1.1 http://localhost/status/504?latencyInMs=60000
INFO in app: >>     Header : Host : localhost
INFO in app: >>     Header : User-Agent : curl/7.54.0
INFO in app: >>     Header : Accept : */*
INFO in app: >>     Query  : latencyInMs : 60000
INFO in app: >>     Body   : b''
INFO in app: << Waiting for timeout exhaust: 60000ms.
INFO in app: < [ HTTP 504 ]

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

http-reqtrace-1.1.0.tar.gz (3.9 kB view details)

Uploaded Source

File details

Details for the file http-reqtrace-1.1.0.tar.gz.

File metadata

  • Download URL: http-reqtrace-1.1.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.6

File hashes

Hashes for http-reqtrace-1.1.0.tar.gz
Algorithm Hash digest
SHA256 757795578349287d911024eb8eb6609bcf0ea94efa4df407368191d2b8a6f7ea
MD5 bd9012a5f21a383ca5d5fa5efb984a71
BLAKE2b-256 a86b383e1d65f65308281f066c63a2a1499e0cfe02879b9b125a8a1687c288d2

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