Socket
Socket
Sign inDemoInstall

http-reqtrace

Package Overview
Dependencies
69
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    http-reqtrace

A simple NodeJS application to view HTTP request details.


Version published
Weekly downloads
0
Maintainers
1
Created
Weekly downloads
 

Readme

Source

npm version license downloads docker-image-version 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 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"}
http > [ GET ] HTTP/ 1.1   http://localhost/context/uri?param1=value1&param2=value2
http >>     Header :  host : localhost
http >>     Header :  user-agent : curl/7.54.0
http >>     Header :  accept : */*
http >>     Header :  authorization : Bearer jwt
http >>     Query  :  { param1: 'value1', param2: 'value2' }
http >>     Body   :  {}
http < [ 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"}
http > [ GET ] HTTP/ 1.1   http://localhost/status/404
http >>     Header :  host : localhost
http >>     Header :  user-agent : curl/7.54.0
http >>     Header :  accept : */*
http >>     Header :  authorization : Bearer jwt
http >>     Query  : {}
http >>     Body   : {}
http < [ HTTP 404 ]
http > [ GET ] HTTP/ 1.1   http://localhost/status/500
http >>     Header :  host : localhost
http >>     Header :  user-agent : curl/7.54.0
http >>     Header :  accept : */*
http >>     Header :  authorization : Bearer jwt
http >>     Query  : {}
http >>     Body   : {}
http < [ HTTP 500 ]

Simulate latency

$ curl http://localhost/status/504?latencyInMs=60000
{"statusCode":504,"message":"KO"}
http > [ GET ] HTTP/ 1.1   http://localhost/status/504
http >>     Header :  host : localhost
http >>     Header :  user-agent : curl/7.54.0
http >>     Header :  accept : */*
http >>     Query  : {}
http >>     Body   : {}
<60s waiting...>
http < [ HTTP 504 ]

FAQs

Last updated on 28 Oct 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc