aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
blob: db4966440bceaae5ff97291714e2147bab0078ab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# httpdump

Parse HTTP requests and responses into JSON.

## Installation

```bash
uv sync
```

## Usage

```bash
# Parse HTTP request from stdin
nc -lp 8080 | uv run httpdump

# Parse HTTP response
curl -si https://example.com | uv run httpdump --response

# Parse from file
uv run httpdump request.txt
uv run httpdump --response response.txt
```

## Output Format

### Request
```json
{
  "method": "POST",
  "url": "/api/users?page=1",
  "path": "/api/users",
  "query_params": {"page": "1"},
  "headers": {
    "raw_base64": "...",
    "parsed": {"Content-Type": "application/json", "Host": "example.com"}
  },
  "body": {
    "raw_base64": "...",
    "json": {"name": "John"}
  }
}
```

### Response
```json
{
  "status_code": 200,
  "status_text": "OK",
  "headers": {
    "raw_base64": "...",
    "parsed": {"Content-Type": "application/json"}
  },
  "body": {
    "raw_base64": "...",
    "json": {"id": 1}
  }
}
```

## Body Parsing

Body is parsed based on Content-Type:
- `application/json``body.json`
- `application/x-www-form-urlencoded``body.form`
- `multipart/form-data``body.multipart`

Raw body is always available as base64 in `body.raw_base64`.

## Options

- `-r, --response` - Parse as HTTP response instead of request