Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Test go code

on:
workflow_dispatch:
pull_request:
paths:
- '**.go'
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ linters:
exclude-functions:
- fmt.Fprintln
- fmt.Fprintf
- fmt.Fprint
wrapcheck:
ignore-package-globs:
- encoding/*
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
- repo: https://github.com/TekWizely/pre-commit-golang
rev: v1.0.0-rc.1
hooks:
- id: golangci-lint
- id: golangci-lint-mod
- id: go-mod-tidy
153 changes: 149 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ Start the server;
basichttpdebugger # listens at :9002
```

> **Note:** The URL path doesn't matter. The server captures **all** incoming
> requests regardless of the path. `http://localhost:9002/`,
> `http://localhost:9002/webhook`, `http://localhost:9002/api/v1/users` - they
> all work the same way. The paths used in examples below (`/login`, `/upload`,
> etc.) are just for illustration purposes.

Listen different port:

```bash
Expand Down Expand Up @@ -368,8 +374,8 @@ Here is how it looks, a GitHub webhook (trimmed, masked due to it’s huge/priva
{"action":"created","issue":{"url": ...} ... }
----------------------------------------------------------------------------------------------------

If you are checking secret token/secret token header (`test`, `X-Gitlab-Token`),
youll see something like this in Payload section:
If you are checking secret token/secret token header (`test`, `X-Gitlab-Token`),
you'll see something like this in Payload section:

+-----------------------------------+-----------------------------+
| Payload | |
Expand All @@ -381,6 +387,133 @@ you’ll see something like this in Payload section:

---

## Form Data Support

The debugger supports `application/x-www-form-urlencoded` content type. Form
data is parsed and displayed in a table format:

```bash
curl -X POST http://localhost:9002/login \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=john&password=secret123&remember=true"
```

Output:

+-----------------------------------------------------+
| Payload |
+--------------+--------------------------------------+
| Incoming | application/x-www-form-urlencoded |
+--------------+--------------------------------------+
| Form Data |
+--------------+--------------------------------------+
| password | secret123 |
| remember | true |
| username | john |
+--------------+--------------------------------------+

Form fields are sorted alphabetically. Multiple values for the same key are
displayed comma-separated:

```bash
curl -X POST http://localhost:9002/colors \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "color=red&color=green&color=blue"
```

Output:

+--------------+--------------------------------------+
| Form Data |
+--------------+--------------------------------------+
| color | red, green, blue |
+--------------+--------------------------------------+

URL-encoded special characters are automatically decoded:

```bash
curl -X POST http://localhost:9002/search \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "email=user%40example.com&query=hello+world"
```

Output:

+--------------+--------------------------------------+
| Form Data |
+--------------+--------------------------------------+
| email | user@example.com |
| query | hello world |
+--------------+--------------------------------------+

---

## File Upload Support

The debugger supports `multipart/form-data` content type for file uploads.
Both form fields and files are parsed and displayed:

```bash
curl -X POST http://localhost:9002/upload \
-F "username=vigo" \
-F "description=Test upload" \
-F "config=@config.json"
```

Output:

+-----------------------------------------------------+
| Payload |
+--------------+--------------------------------------+
| Incoming | multipart/form-data; boundary=... |
+--------------+--------------------------------------+
| Form Data |
+--------------+--------------------------------------+
| description | Test upload |
| username | vigo |
+--------------+--------------------------------------+
| Files |
+--------------+--------------------------------------+
| config.json | 18 B | application/json |
| {"theme": "dark"} |
+-----------------------------------------------------+

File metadata is displayed for all uploaded files:

```bash
curl -X POST http://localhost:9002/upload \
-F "avatar=@photo.png"
```

Output:

+-----------------------------------------------------+
| Files |
+-----------------------------------------------------+
| photo.png | 2.5 KB | application/octet-stream |
+-----------------------------------------------------+

For small text files (under 1KB), the content is displayed. For larger files
or binary files, only metadata (filename, size, content-type) is shown.

**Image Preview in Web Dashboard:** When you upload image files (JPEG, PNG, GIF,
etc.), the web dashboard displays a preview of the image alongside the file
metadata.

Multiple files can be uploaded at once:

```bash
curl -X POST http://localhost:9002/upload \
-F "file1=@readme.txt" \
-F "file2=@data.json" \
-F "image=@logo.png"
```

Form fields and files are displayed in separate sections, both in the terminal
and in the web dashboard.

---

## Docker

For local docker usage, default expose port is: `9002` (debug) and `9003` (web dashboard).
Expand Down Expand Up @@ -450,6 +583,19 @@ rake test # run test

## Change Log

**2026-01-23**

- add `application/x-www-form-urlencoded` content type support
- add `multipart/form-data` content type support for file uploads
- form data is parsed and displayed in table format
- file uploads show metadata (filename, size, content-type)
- small text files (under 1KB) display content inline
- multiple values for the same key are comma-separated
- URL-encoded characters are automatically decoded
- web dashboard supports form data and file upload display
- web dashboard shows image preview for uploaded images (JPEG, PNG, GIF, etc.)
- binary file content is sanitized in terminal output (`[binary data: X KB]`)

**2025-01-23**

- add web dashboard for real-time request monitoring (similar to ngrok)
Expand Down Expand Up @@ -489,8 +635,7 @@ rake test # run test

## TODO

- Add http form requests support
- Add http file upload requests support
- Add brew tap installation support

---

Expand Down
Loading