Skip to content

Commit 8dc23e2

Browse files
committed
update docs
1 parent bf39b27 commit 8dc23e2

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ SimpleHTTPserver is a go enhanced version of the well known python simplehttpser
2929
- HTTP/S Web Server
3030
- File Server with arbitrary directory support
3131
- HTTP request/response dump
32+
- JSON request logging to file
3233
- Configurable ip address and listening port
3334
- Configurable HTTP/TCP server with customizable response via YAML template
3435

@@ -72,6 +73,7 @@ This will display help for the tool. Here are all the switches it supports.
7273
| `-silent` | Show only results | `simplehttpserver -silent` |
7374
| `-py` | Emulate Python Style | `simplehttpserver -py` |
7475
| `-header` | HTTP response header (can be used multiple times) | `simplehttpserver -header 'X-Powered-By: Go'` |
76+
| `-json-log` | JSON log file path for request logging | `simplehttpserver -json-log /tmp/requests.json` |
7577

7678
### Running simplehttpserver in the current folder
7779

@@ -121,6 +123,39 @@ To upload files use the following curl request with basic auth header:
121123
curl -v --user 'root:root' --upload-file file.txt http://localhost:8000/file.txt
122124
```
123125

126+
### Running simplehttpserver with JSON request logging
127+
128+
This will run the tool and log all HTTP requests to a JSON file:
129+
130+
```sh
131+
simplehttpserver -json-log /tmp/requests.json
132+
133+
2021/01/11 21:40:48 Serving . on http://0.0.0.0:8000/...
134+
```
135+
136+
The JSON log file will contain structured request data including:
137+
- Timestamp, remote address, HTTP method, URL, protocol
138+
- Status code, response size, user agent
139+
- Request headers, request body, response body
140+
141+
Example JSON log entry:
142+
```json
143+
{
144+
"timestamp": "2021-01-11T21:41:15Z",
145+
"remote_addr": "127.0.0.1:50181",
146+
"method": "GET",
147+
"url": "/",
148+
"proto": "HTTP/1.1",
149+
"status_code": 200,
150+
"size": 383,
151+
"user_agent": "curl/7.68.0",
152+
"headers": {
153+
"Accept": "*/*",
154+
"User-Agent": "curl/7.68.0"
155+
}
156+
}
157+
```
158+
124159
### Running TCP server with custom responses
125160

126161
This will run the tool as TLS TCP server and enable custom responses based on YAML templates:

0 commit comments

Comments
 (0)