magohl / HttpBucket

Http request bucket. Capture and display HTTP messages. Use request URL to control desired response. Perfect companion when doing API development. Spin up a copy on a docker environment near you. On premise and cloud friendly!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Http Bucket

Background

I use services like Requestbin to capture HTTP requests alot while developing or troubleshooting. This is my 'lightweight' take on such a service, doing the things that I need and that work in a docker/kubernetes environment. By just adding some parameters to the request URL you can control the HTTP-response code, headers and even add a (small) response body.

Features

  • Requests persisted in memory
  • Websockets will push updates to connected clients
  • By default an HTTP/200 OK is returned. If you want something else just add the response status code before the bucket id.
  • GET, POST, PUT, DELETE

How to use

Create bucket

Create a new bucket by doing a simple get to /ui/{some-new-guid} or by using the 'button' on /ui

UI

https://somehost/ui/{BUCKET-GUID}

Return custom Http Response Code

https://somehost/{HTTP-RESPOSNE-CODE}/{BUCKET-GUID}/{whatever-url}
Example: HTTP GET/POST/PUT/DELETE to URL
https://somehost/405/fe6d3ace-538c-41c3-8141-c9203ab6efb0/foo/bar

This would log the request and return

  • HTTP/405
  • Empty body

Return custom Http Response code, headers and body

https://somehost/{HTTP-RESPOSNE-CODE}/{BASE64-ENCODED-LIST-OF '|' SEPARATED-HTTP-HEADERS}/{BASE64-ENCODED-RESPONSE-BODY}/{BUCKET-GUID}/{whatever-url}
Example: HTTP GET/POST/PUT/DELETE to URL
https://somehost/201/Q29udGVudC10eXBlPWFwcGxpY2F0aW9uL2pzb24=/eyJpY2VjcmVhbXRydWNrIiA6IHRydWV9/fe6d3ace-538c-41c3-8141-c9203ab6efb0/foo

The would log the request and return

  • HTTP/201
  • Content-type: application/json
  • Response body {"icecreamtruck" : true}

Note that this only work for small payloads as a typical max request URL is 2Mb. Base64 encoding adds ~30% but something like a 1Mb response body should work fine in most scenarios.

Example forcing a 401 WWW-Authenticate

This is an example how to troubleshoot Basic authentication issues. Say you want to capture a request and investigate if the Basic Authentication header was set as expected. Some platforms will not add basic authentication headers to outgoing messages if the service does not conform 100% to the Basic Authentication specification and returns a 401 with header "WWW-Authenticate: Basic".

Using HttpBucket you can have it return a 401 header "WWW-Authenticate: Basic". You will then end up with two calls to the Bucket where the second one should contain the Authorization header.

https://somehost/401/V1dXLUF1dGhlbnRpY2F0ZT1CYXNpYw==/dGVzdC1yZXNwb25zZQ==/07aa6c39-ae94-4efc-b932-4039c2b3ed6e/bar

Technology

  • Dotnet 5.0 and Asp.Net Core 5
  • SignalR Core

Run in docker

docker run -p 8080:80 magohl/httpbucket:latest

Run in docker behind one (or more) reverse proxies docker run -p 8080:80 -e ASPNETCORE_FORWARDEDHEADERS_ENABLED=true magohl/httpbucket:latest

How does it look?

HttpBucket_v1 0

Todo

  • Clean bucket button
  • OIDC login to create/view buckets
  • Simple DB backend
  • A new and better request header display
  • Return headers and response body based on request input

About

Http request bucket. Capture and display HTTP messages. Use request URL to control desired response. Perfect companion when doing API development. Spin up a copy on a docker environment near you. On premise and cloud friendly!


Languages

Language:C# 64.0%Language:HTML 24.4%Language:JavaScript 6.2%Language:CSS 3.1%Language:Dockerfile 2.4%