httptest-cli 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- httptest_cli-0.1.0/LICENSE +21 -0
- httptest_cli-0.1.0/PKG-INFO +235 -0
- httptest_cli-0.1.0/README.md +205 -0
- httptest_cli-0.1.0/httptest/__init__.py +3 -0
- httptest_cli-0.1.0/httptest/cli.py +651 -0
- httptest_cli-0.1.0/httptest_cli.egg-info/PKG-INFO +235 -0
- httptest_cli-0.1.0/httptest_cli.egg-info/SOURCES.txt +11 -0
- httptest_cli-0.1.0/httptest_cli.egg-info/dependency_links.txt +1 -0
- httptest_cli-0.1.0/httptest_cli.egg-info/entry_points.txt +2 -0
- httptest_cli-0.1.0/httptest_cli.egg-info/requires.txt +1 -0
- httptest_cli-0.1.0/httptest_cli.egg-info/top_level.txt +1 -0
- httptest_cli-0.1.0/pyproject.toml +45 -0
- httptest_cli-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Marcus
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: httptest-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Local HTTP test server CLI - echo, static files, mock APIs
|
|
5
|
+
Author-email: Marcus <marcus.builds.things@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/marcusbuildsthings-droid/httptest
|
|
8
|
+
Project-URL: Repository, https://github.com/marcusbuildsthings-droid/httptest
|
|
9
|
+
Project-URL: Issues, https://github.com/marcusbuildsthings-droid/httptest/issues
|
|
10
|
+
Keywords: http,server,testing,mock,api,development,cli
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
|
|
23
|
+
Classifier: Topic :: Software Development :: Testing
|
|
24
|
+
Classifier: Topic :: Software Development :: Testing :: Mocking
|
|
25
|
+
Requires-Python: >=3.8
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: click>=8.0
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# httptest
|
|
32
|
+
|
|
33
|
+
Local HTTP test server CLI for development. Echo requests, serve static files, or mock APIs.
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install httptest-cli
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Quick Start
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Echo all requests back as JSON
|
|
45
|
+
httptest echo
|
|
46
|
+
|
|
47
|
+
# Serve static files
|
|
48
|
+
httptest static ./public
|
|
49
|
+
|
|
50
|
+
# Mock API from JSON spec
|
|
51
|
+
httptest mock api.json
|
|
52
|
+
|
|
53
|
+
# Record requests to file
|
|
54
|
+
httptest record -o requests.jsonl
|
|
55
|
+
|
|
56
|
+
# Replay recorded requests
|
|
57
|
+
httptest replay requests.jsonl -t http://localhost:3000
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Commands
|
|
61
|
+
|
|
62
|
+
### echo
|
|
63
|
+
|
|
64
|
+
Echo all incoming requests back as JSON. Useful for debugging webhooks or API clients.
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
httptest echo # Start on port 8080
|
|
68
|
+
httptest echo -p 3000 # Custom port
|
|
69
|
+
httptest echo -r requests.jsonl # Record all requests
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Response format:
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"timestamp": "2026-02-04T12:00:00.000Z",
|
|
76
|
+
"method": "POST",
|
|
77
|
+
"path": "/webhook",
|
|
78
|
+
"query": {"foo": ["bar"]},
|
|
79
|
+
"headers": {"Content-Type": "application/json", ...},
|
|
80
|
+
"body": {"event": "user.created"},
|
|
81
|
+
"client": {"address": "127.0.0.1", "port": 54321}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### static
|
|
86
|
+
|
|
87
|
+
Serve static files from a directory with automatic index.html and directory listings.
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
httptest static ./public # Serve ./public directory
|
|
91
|
+
httptest static . -p 3000 # Current dir on port 3000
|
|
92
|
+
httptest static dist --index main.html # Custom index file
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### mock
|
|
96
|
+
|
|
97
|
+
Serve mock API responses from a JSON spec file.
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
httptest mock api.json
|
|
101
|
+
httptest mock spec.json -p 3000
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Spec file format:**
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"GET /users": {
|
|
109
|
+
"body": [
|
|
110
|
+
{"id": 1, "name": "Alice"},
|
|
111
|
+
{"id": 2, "name": "Bob"}
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
"POST /users": {
|
|
115
|
+
"status": 201,
|
|
116
|
+
"body": {"id": 3, "message": "Created"}
|
|
117
|
+
},
|
|
118
|
+
"GET /slow": {
|
|
119
|
+
"body": {"status": "ok"},
|
|
120
|
+
"delay": 1000
|
|
121
|
+
},
|
|
122
|
+
"/health": {
|
|
123
|
+
"body": {"status": "healthy"}
|
|
124
|
+
},
|
|
125
|
+
"GET /users/*": {
|
|
126
|
+
"body": {"id": 1, "name": "User"}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Route keys:
|
|
132
|
+
- `"METHOD /path"` - match specific HTTP method
|
|
133
|
+
- `"/path"` - match any method
|
|
134
|
+
- `"/path/*"` - wildcard matching
|
|
135
|
+
|
|
136
|
+
Response options:
|
|
137
|
+
- `body` or `response` - response body (objects become JSON)
|
|
138
|
+
- `status` - HTTP status code (default: 200)
|
|
139
|
+
- `headers` - custom response headers
|
|
140
|
+
- `delay` - response delay in milliseconds
|
|
141
|
+
|
|
142
|
+
### record
|
|
143
|
+
|
|
144
|
+
Record all incoming requests to a JSONL file.
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
httptest record # Record to requests.jsonl
|
|
148
|
+
httptest record -o webhooks.jsonl
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### replay
|
|
152
|
+
|
|
153
|
+
Replay recorded requests against a target server.
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
httptest replay requests.jsonl -t http://localhost:3000
|
|
157
|
+
httptest replay webhooks.jsonl -t https://staging.api.com -d 100
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Options:
|
|
161
|
+
- `-t, --target` - Target URL base (required)
|
|
162
|
+
- `-d, --delay` - Delay between requests in ms
|
|
163
|
+
- `--json` - Output results as JSON
|
|
164
|
+
|
|
165
|
+
### fixed
|
|
166
|
+
|
|
167
|
+
Return a fixed response for all requests.
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
httptest fixed # Returns "ok" with 200
|
|
171
|
+
httptest fixed --status 503 --body "maintenance"
|
|
172
|
+
httptest fixed --body '{"status":"healthy"}' --content-type application/json
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Common Options
|
|
176
|
+
|
|
177
|
+
All server commands support:
|
|
178
|
+
- `-p, --port` - Port to listen on (default: 8080)
|
|
179
|
+
- `-H, --host` - Host to bind to (default: 0.0.0.0)
|
|
180
|
+
- `--no-cors` - Disable CORS headers
|
|
181
|
+
- `-q, --quiet` - Suppress startup message
|
|
182
|
+
|
|
183
|
+
## Use Cases
|
|
184
|
+
|
|
185
|
+
### Webhook Development
|
|
186
|
+
|
|
187
|
+
Test webhooks locally by echoing requests:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
httptest echo -p 9999 -r webhooks.jsonl
|
|
191
|
+
# Configure your service to send webhooks to http://localhost:9999
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### API Prototyping
|
|
195
|
+
|
|
196
|
+
Mock an API before it's built:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
# api.json
|
|
200
|
+
{
|
|
201
|
+
"GET /api/users": {"body": [{"id": 1, "name": "Test"}]},
|
|
202
|
+
"POST /api/users": {"status": 201, "body": {"id": 2}},
|
|
203
|
+
"GET /api/users/*": {"body": {"id": 1, "name": "User"}}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
httptest mock api.json -p 3001
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Frontend Development
|
|
210
|
+
|
|
211
|
+
Serve your frontend build:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
httptest static ./dist -p 8000
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Load Testing Prep
|
|
218
|
+
|
|
219
|
+
Record production traffic, then replay against staging:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# Record
|
|
223
|
+
httptest record -p 8080 -o traffic.jsonl
|
|
224
|
+
|
|
225
|
+
# Replay
|
|
226
|
+
httptest replay traffic.jsonl -t http://staging.example.com
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## For AI Agents
|
|
230
|
+
|
|
231
|
+
See [SKILL.md](SKILL.md) for agent-optimized documentation.
|
|
232
|
+
|
|
233
|
+
## License
|
|
234
|
+
|
|
235
|
+
MIT
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# httptest
|
|
2
|
+
|
|
3
|
+
Local HTTP test server CLI for development. Echo requests, serve static files, or mock APIs.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install httptest-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Echo all requests back as JSON
|
|
15
|
+
httptest echo
|
|
16
|
+
|
|
17
|
+
# Serve static files
|
|
18
|
+
httptest static ./public
|
|
19
|
+
|
|
20
|
+
# Mock API from JSON spec
|
|
21
|
+
httptest mock api.json
|
|
22
|
+
|
|
23
|
+
# Record requests to file
|
|
24
|
+
httptest record -o requests.jsonl
|
|
25
|
+
|
|
26
|
+
# Replay recorded requests
|
|
27
|
+
httptest replay requests.jsonl -t http://localhost:3000
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Commands
|
|
31
|
+
|
|
32
|
+
### echo
|
|
33
|
+
|
|
34
|
+
Echo all incoming requests back as JSON. Useful for debugging webhooks or API clients.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
httptest echo # Start on port 8080
|
|
38
|
+
httptest echo -p 3000 # Custom port
|
|
39
|
+
httptest echo -r requests.jsonl # Record all requests
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Response format:
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"timestamp": "2026-02-04T12:00:00.000Z",
|
|
46
|
+
"method": "POST",
|
|
47
|
+
"path": "/webhook",
|
|
48
|
+
"query": {"foo": ["bar"]},
|
|
49
|
+
"headers": {"Content-Type": "application/json", ...},
|
|
50
|
+
"body": {"event": "user.created"},
|
|
51
|
+
"client": {"address": "127.0.0.1", "port": 54321}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### static
|
|
56
|
+
|
|
57
|
+
Serve static files from a directory with automatic index.html and directory listings.
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
httptest static ./public # Serve ./public directory
|
|
61
|
+
httptest static . -p 3000 # Current dir on port 3000
|
|
62
|
+
httptest static dist --index main.html # Custom index file
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### mock
|
|
66
|
+
|
|
67
|
+
Serve mock API responses from a JSON spec file.
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
httptest mock api.json
|
|
71
|
+
httptest mock spec.json -p 3000
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Spec file format:**
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"GET /users": {
|
|
79
|
+
"body": [
|
|
80
|
+
{"id": 1, "name": "Alice"},
|
|
81
|
+
{"id": 2, "name": "Bob"}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
"POST /users": {
|
|
85
|
+
"status": 201,
|
|
86
|
+
"body": {"id": 3, "message": "Created"}
|
|
87
|
+
},
|
|
88
|
+
"GET /slow": {
|
|
89
|
+
"body": {"status": "ok"},
|
|
90
|
+
"delay": 1000
|
|
91
|
+
},
|
|
92
|
+
"/health": {
|
|
93
|
+
"body": {"status": "healthy"}
|
|
94
|
+
},
|
|
95
|
+
"GET /users/*": {
|
|
96
|
+
"body": {"id": 1, "name": "User"}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Route keys:
|
|
102
|
+
- `"METHOD /path"` - match specific HTTP method
|
|
103
|
+
- `"/path"` - match any method
|
|
104
|
+
- `"/path/*"` - wildcard matching
|
|
105
|
+
|
|
106
|
+
Response options:
|
|
107
|
+
- `body` or `response` - response body (objects become JSON)
|
|
108
|
+
- `status` - HTTP status code (default: 200)
|
|
109
|
+
- `headers` - custom response headers
|
|
110
|
+
- `delay` - response delay in milliseconds
|
|
111
|
+
|
|
112
|
+
### record
|
|
113
|
+
|
|
114
|
+
Record all incoming requests to a JSONL file.
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
httptest record # Record to requests.jsonl
|
|
118
|
+
httptest record -o webhooks.jsonl
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### replay
|
|
122
|
+
|
|
123
|
+
Replay recorded requests against a target server.
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
httptest replay requests.jsonl -t http://localhost:3000
|
|
127
|
+
httptest replay webhooks.jsonl -t https://staging.api.com -d 100
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Options:
|
|
131
|
+
- `-t, --target` - Target URL base (required)
|
|
132
|
+
- `-d, --delay` - Delay between requests in ms
|
|
133
|
+
- `--json` - Output results as JSON
|
|
134
|
+
|
|
135
|
+
### fixed
|
|
136
|
+
|
|
137
|
+
Return a fixed response for all requests.
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
httptest fixed # Returns "ok" with 200
|
|
141
|
+
httptest fixed --status 503 --body "maintenance"
|
|
142
|
+
httptest fixed --body '{"status":"healthy"}' --content-type application/json
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Common Options
|
|
146
|
+
|
|
147
|
+
All server commands support:
|
|
148
|
+
- `-p, --port` - Port to listen on (default: 8080)
|
|
149
|
+
- `-H, --host` - Host to bind to (default: 0.0.0.0)
|
|
150
|
+
- `--no-cors` - Disable CORS headers
|
|
151
|
+
- `-q, --quiet` - Suppress startup message
|
|
152
|
+
|
|
153
|
+
## Use Cases
|
|
154
|
+
|
|
155
|
+
### Webhook Development
|
|
156
|
+
|
|
157
|
+
Test webhooks locally by echoing requests:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
httptest echo -p 9999 -r webhooks.jsonl
|
|
161
|
+
# Configure your service to send webhooks to http://localhost:9999
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### API Prototyping
|
|
165
|
+
|
|
166
|
+
Mock an API before it's built:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# api.json
|
|
170
|
+
{
|
|
171
|
+
"GET /api/users": {"body": [{"id": 1, "name": "Test"}]},
|
|
172
|
+
"POST /api/users": {"status": 201, "body": {"id": 2}},
|
|
173
|
+
"GET /api/users/*": {"body": {"id": 1, "name": "User"}}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
httptest mock api.json -p 3001
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Frontend Development
|
|
180
|
+
|
|
181
|
+
Serve your frontend build:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
httptest static ./dist -p 8000
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Load Testing Prep
|
|
188
|
+
|
|
189
|
+
Record production traffic, then replay against staging:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
# Record
|
|
193
|
+
httptest record -p 8080 -o traffic.jsonl
|
|
194
|
+
|
|
195
|
+
# Replay
|
|
196
|
+
httptest replay traffic.jsonl -t http://staging.example.com
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## For AI Agents
|
|
200
|
+
|
|
201
|
+
See [SKILL.md](SKILL.md) for agent-optimized documentation.
|
|
202
|
+
|
|
203
|
+
## License
|
|
204
|
+
|
|
205
|
+
MIT
|