Skip to content

Commit 21a94be

Browse files
committed
prepare to v4.1.1
1 parent 118a01d commit 21a94be

File tree

3 files changed

+108
-118
lines changed

3 files changed

+108
-118
lines changed

Cheatsheet.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -776,10 +776,7 @@ Prepare file <code>dump.txt</code>:
776776
GET /favicon.ico HTTP/1.1
777777
778778
HTTP/1.1 200 OK
779-
Content-Type: image/vnd.microsoft.icon
780-
X-Body-Type: text/uri-list
781-
782-
data:image/vnd.microsoft.icon;base64,AAABAAEAEBAAAAEAGABoAwAAFgAAACgAAAAQAA
779+
X-Content-Source: data:image/vnd.microsoft.icon;base64,AAABAAEAEBAAAAEAGABoAwAAFgAAACgAAAAQAA
783780
AAIAAAAAEAGAAAAAAAAAMAABILAAASCwAAAAAAAAAAAAASVuwSVuwSVuwSVuwAif8Aif8Aif8A
784781
if8Aif8Aif8Aif8Aif8SVuwSVuwSVuwSVuwSVuwSVuwAif8Aif8Aif8Aif8Aif8Aif8Aif8Aif
785782
8Aif8Aif8Aif8Aif8SVuwSVuwSVuwAif8Aif8Aif8Aif8Aif8Aif8Aif8Aif8Aif8Aif8Aif8A
@@ -821,8 +818,8 @@ The <img src="https://raw.githubusercontent.com/xnbox/DeepfakeHTTP/main/img/favi
821818
<br>
822819
<strong>⚡️ Hacks and Tips:</strong><br>
823820
<ul>
824-
<li>Serve any media type by using <code>X-Body-Type: text/uri-list</code> and appropriate <code>Content-Type</code>response headers.</li>
825-
<li>With <code>X-Body-Type: text/uri-list</code> response header you can use also <code>http://</code>, <code>https://</code> and <code>file://</code> URLs.</li>
821+
<li>Serve any media type by using <code>X-Content-Source</code> response header.</li>
822+
<li>With <code>X-Content-Source</code></code> response header you can use also <code>http://</code>, <code>https://</code>, <code>file://</code>, and <code>data://</code> URLs.</li>
826823
<li>Don't miss a single carriage return between headers and body!</li>
827824
</ul>
828825
<strong>💡 See Also:</strong>
@@ -844,9 +841,7 @@ GET /Albert_Einstein.jpeg HTTP/1.1
844841
845842
HTTP/1.1 200 OK
846843
Content-Type: image/jpeg
847-
X-Body-Type: text/uri-list
848-
849-
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAZABkAAD/2wBDAAMCAgICAgMCAgIDAwMDB
844+
X-Content-Source: data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAZABkAAD/2wBDAAMCAgICAgMCAgIDAwMDB
850845
AYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/2wBDAQMDA
851846
wQDBAgEBAgQCwkLEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE
852847
BAQEBD/wgARCABkAGQDASIAAhEBAxEB/8QAHAAAAQQDAQAAAAAAAAAAAAAABwADBQYCBAgB/8QAG
@@ -958,8 +953,8 @@ Get response:<br>
958953
<br>
959954
<strong>⚡️ Hacks and Tips:</strong><br>
960955
<ul>
961-
<li>Serve any media type by using <code>X-Body-Type: text/uri-list</code> and appropriate <code>Content-Type</code>response headers.</li>
962-
<li>With <code>X-Body-Type: text/uri-list</code> response header you can use also <code>http://</code>, <code>https://</code> and <code>file://</code> URLs.</li>
956+
<li>Serve any media type by using <code>X-Content-Source</code> response header.</li>
957+
<li>With <code>X-Content-Source</code></code> response header you can use also <code>http://</code>, <code>https://</code>, <code>file://</code>, and <code>data://</code> URLs.</li>
963958
</ul>
964959
<strong>💡 See Also:</strong>
965960
<ul>
@@ -1162,9 +1157,8 @@ View generated <a href="https://raw.githubusercontent.com/xnbox/DeepfakeHTTP/mai
11621157
<strong>⚡️ Hacks and Tips:</strong><br>
11631158
<ul>
11641159
<li>Parameters are always treated as strings.</li>
1165-
<li>If response body content is a plain character data you don't need <code>X-Body-Type</code> header.</li>
1166-
<li>Serve any media type by using <code>X-Body-Type: text/uri-list</code> and appropriate <code>Content-Type</code>response headers.</li>
1167-
<li>With <code>X-Body-Type: text/uri-list</code> response header you can use also <code>http://</code>, <code>https://</code> and <code>file://</code> URLs.</li>
1160+
<li>Serve any media type by using <code>X-Content-Source</code> response header.</li>
1161+
<li>With <code>X-Content-Source</code></code> response header you can use also <code>http://</code>, <code>https://</code>, <code>file://</code>, and <code>data://</code> URLs.</li>
11681162
</ul>
11691163
<strong>💡 See Also:</strong>
11701164
<ul>
@@ -1219,6 +1213,7 @@ java -jar df.jar --print-openapi --openapi-title 'Acme CRM REST API' --dump dump
12191213
</ul>
12201214
<strong>💡 See Also:</strong>
12211215
<ul>
1222-
</ul>
1216+
<li><a href="#">Work in progress</a></li>
1217+
<ul>
12231218
</td></tr></table>
12241219
<!-- -------------------------------------------------------------------- -->

README.md

Lines changed: 97 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Your 100% static dynamic backend</h1>
33

44
<a title="License MIT" href="https://github.com/xnbox/DeepfakeHTTP/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue?style=flat-square"></a>
5-
<a title="Release 3.2.1" href="https://github.com/xnbox/DeepfakeHTTP/releases"><img src="https://img.shields.io/badge/release-3.2.1-4DC71F?style=flat-square"></a>
5+
<a title="Release 4.1.1" href="https://github.com/xnbox/DeepfakeHTTP/releases"><img src="https://img.shields.io/badge/release-4.1.1-4DC71F?style=flat-square"></a>
66
<a title="Powered by Tommy" href="https://github.com/xnbox/tommy"><img src="https://img.shields.io/badge/powered_by-Tommy-blueviolet?style=flat-square"></a>
77

88
<p align="center">
@@ -18,7 +18,7 @@ Your 100% static dynamic backend</h1>
1818
<td>
1919
<h3>What are people using it for?</h3>
2020
<ul>
21-
<li>Creating the product POC or demo before even starting out with the backend</li>
21+
<li>Creating the product PoC or demo before even starting out with the backend</li>
2222
<li>REST, GraphQL, and other APIs mocking and testing</li>
2323
<li>Hiding critical enterprise infrastructure behind a simple static facade</li>
2424
<li>Hacking and fine-tuning HTTP communications on both server and client sides</li>
@@ -75,35 +75,38 @@ For more examples, see the <a href="Cheatsheet.md">cheatsheet</a>.
7575
```
7676
java -jar df.jar [OPTIONS] [FLAGS] [COMMANDS]
7777
78-
OPTIONS:
79-
--port <number> HTTP TCP port number, default: 8080
80-
--port-ssl <number> HTTPS TCP port number, default: 8443
81-
--dump <file|url>... dump text file(s) and/or OpenAPI json/yaml file(s)
82-
--data <file|url>... json/yaml/csv data file(s) to populate templates
83-
--openapi-path <path> serve OpenAPI client at specified context path
84-
--openapi-title <text> provide custom OpenAPI spec title
85-
--collect <file> collect live request/response to file
86-
--format <json|yaml> output format for --print-* commands, default: json
87-
--status <number> status code for non-matching requests, default: 400
88-
89-
FLAGS:
90-
--no-log disable request/response console logging
91-
--no-cors disable CORS headers
92-
--no-etag disable 'ETag' header
93-
--no-powered-by disable 'X-Powered-By' header
94-
--no-watch disable watch files for changes
95-
--no-color disable ANSI color output for --print-* commands
96-
--no-pretty disable prettyprint for --print-* commands
97-
--no-template disable template processing
98-
--no-wildcard disable wildcard processing
99-
--strict-json enable strict JSON comparison
100-
--redirect enable redirect HTTP to HTTPS
101-
102-
COMMANDS:
103-
--help print help message
104-
--print-info print dump files statistics to stdout as json/yaml
105-
--print-requests print dump requests to stdout as json/yaml
106-
--print-openapi print OpenAPI specification to stdout as json/yaml
78+
OPTIONS:
79+
--port <number> HTTP TCP port number, default: 8080
80+
--port-ssl <number> HTTPS TCP port number, default: 8443
81+
--dump <file|url>... dump text file(s) and/or OpenAPI json/yaml file(s)
82+
--data <file|url>... json/yaml/csv data file(s) to populate templates
83+
--openapi-path <path> serve OpenAPI client at specified context path
84+
--openapi-title <text> provide custom OpenAPI spec title
85+
--collect <file> collect live request/response to file
86+
--format <json|yaml> output format for --print-* commands, default: json
87+
--status <number> status code for non-matching requests, default: 400
88+
--max-log-body <number> max body bytes in console log, default: unlimited
89+
90+
FLAGS:
91+
--no-log disable request/response console logging
92+
--no-log-headers disable request/response headers in console logging
93+
--no-log-body disable request/response body in console logging
94+
--no-cors disable CORS headers
95+
--no-etag disable 'ETag' header
96+
--no-powered-by disable 'X-Powered-By' header
97+
--no-watch disable watch files for changes
98+
--no-color disable ANSI color output for --print-* commands
99+
--no-pretty disable prettyprint for --print-* commands
100+
--no-template disable template processing
101+
--no-wildcard disable wildcard processing
102+
--strict-json enable strict JSON comparison
103+
--redirect enable redirect HTTP to HTTPS
104+
105+
COMMANDS:
106+
--help print help message
107+
--print-info print dump files statistics to stdout as json/yaml
108+
--print-requests print dump requests to stdout as json/yaml
109+
--print-openapi print OpenAPI specification to stdout as json/yaml
107110
```
108111

109112
<h2>Usage Exampes</h2>
@@ -171,23 +174,19 @@ java -jar df.jar --print-openapi --dump dump.txt
171174

172175
<h2>How does it work?</h2>
173176
<ol>
174-
<li>Got client request</li>
175-
<li>Search dump entries (request-response pairs) for appropriate entry by matching all specified request parts:<br>
176-
method, URI, headers, and body</li>
177-
<li>If entry is found, the server generates a corresponded response and sends it to the client</li>
178-
<li>If entry is not found, the server search dump entries for response with status <code>400</code> (Bad request).</li>
179-
<li>If entry is found, the server send entry to the client
180-
<li>If entry is not found, the server sends status <code>400</code> with no body.</li>
177+
<li>Got the client's request.</li>
178+
<li>Search the dump for corresponded entry (request-response pair) by matching all specified request's parts:<br>
179+
<i>method</i>, <i>URI</i>, <i>headers</i>, and <i>body</i>.</li>
180+
<li>If the entry was found, the server sends the appropriate response to the client.</li>
181+
<li>If the entry was not found, the server sends a status <code>400</code> (400 Bad request).</li>
181182
</ol>
182183
That's all.
183184

184185
<h2>Features</h2>
185186
<ul>
186-
<li>No dependencies</li>
187-
<li>No installation</li>
188-
<li>No configuration files</li>
189-
<li>Single-file executable</li>
190-
<li>Retrieve response data from HTTP dumps and/or OpenAPI json/yaml</li>
187+
<li>No dependencies, no installation, no configs</li>
188+
<li>Crossplatform single-file executable</li>
189+
<li>Retrieve response data from HTTP dumps and/or OpenAPI JSON/YAML</li>
191190
</ul>
192191
<details>
193192
<summary>
@@ -199,12 +198,11 @@ That's all.
199198
<li>Asynchronous requests and responses</li>
200199
<li>HTTP message formats (RFC 7230)</li>
201200
<li>Unlimited number of request/response pairs in the dump</li>
202-
<li>Scriptable response body</li>
203201
<li>Supports methods: <code>GET</code>, <code>HEAD</code>, <code>POST</code>, <code>PUT</code>, <code>DELETE</code> etc.</li>
204202
<li>Multi-line and multi-value headers (RFC 7230).</li>
205203
<li>OpenAPI-styled templates in paths</li>
206204
<li>Wildcards ( <code> *</code> and <code> ?</code> with escape <code> /</code> ) in query string and header values</li>
207-
<li>Templates in response body</li>
205+
<li>Templates in URI, headers, body</li>
208206
<li>JSON/YAML/CSV data files to populate templates</li>
209207
<li>Response body fetching from external sources like URLs, local files, and data URI</li>
210208
<li>Per entry user-defined request and response delays</li>
@@ -222,22 +220,34 @@ That's all.
222220
</ul>
223221
</details>
224222

225-
<h2>Legal</h2>
226-
<ul>
227-
<li>The DeepfakeHTTP is released under the <a href="https://github.com/xnbox/DeepfakeHTTP/blob/main/LICENSE">MIT</a> license.</li>
228-
<li>Third-party products: <a href="https://raw.githubusercontent.com/xnbox/DeepfakeHTTP/main/THIRD-PARTY">THIRD-PARTY</a></li>
229-
</ul>
223+
<h2>LICENSE</h2>
224+
The DeepfakeHTTP is released under the <a href="https://github.com/xnbox/DeepfakeHTTP/blob/main/LICENSE">MIT</a> license.
230225
<br><br>
231226
<h1></h1>
232227
<br><br>
233228
<h2>
234229
APPENDIX A.
235230
<br>
236-
Optional request headers (OpenAPI)
231+
Optional request headers
237232
</h2>
238233
<table>
239234
<tr><th width="220rem">Header</th><th>Description</th></tr>
240-
<tr></tr>
235+
<tr></tr>
236+
<tr><td valign="top"><code>X-Delay</code></td>
237+
<td><p>Request delay (in milliseconds).</p>
238+
<i>Example:</i>
239+
<br>
240+
241+
```http
242+
# Two seconds request delay.
243+
244+
HTTP/1.1 200 OK
245+
X-Delay: 2000
246+
247+
{"id": 5, "name": "John Doe"}
248+
```
249+
</td></tr>
250+
<tr></tr>
241251
<tr><td valign="top"><code>X-OpenAPI-Summary</code></td>
242252
<td>
243253
<p>OpenAPI request summary text.</p>
@@ -285,8 +295,9 @@ X-OpenAPI-Tags: Work with customer, Buyers, Login info
285295
```
286296
<img width="1000" height="0">
287297
</td></tr>
298+
288299
</table>
289-
<strong>NOTE: </strong>Optional request headers are used as OpenAPI annotations and will <strong>not</strong> be sent to the server engine.
300+
<strong>NOTE: </strong>Optional request headers will <strong>not</strong> be sent to the server engine.
290301
<br><br>
291302

292303

@@ -297,94 +308,78 @@ Optional response headers
297308
</h2>
298309
<table>
299310
<tr><th width="220rem">Header</th><th>Description</th></tr>
300-
<tr></tr>
301-
<tr><td valign="top"><code>X-Body-Type </code></td>
302-
<td>
303-
<p>Tells the server what the content type (media type) of the body content actually is. Value of this header has same rules as value of standard HTTP <code>Content-Type</code> header.</p>
304-
<p>This header is useful when you want to use binary data or script as a response body.</p>
305-
<i>Examples:</i>
306-
<br><br>
307-
308-
A response body is a character data (default).<br>
309-
No <code>X-Body-Type</code> header is needed.
311+
<tr></tr>
312+
<tr><td valign="top"><code>X-Delay</code></td>
313+
<td><p>Response delay (in milliseconds).</p>
314+
<i>Example:</i>
315+
<br>
310316

311317
```http
318+
# Two seconds response delay.
319+
312320
HTTP/1.1 200 OK
313-
Content-Type: application/json
321+
X-Delay: 2000
314322
315323
{"id": 5, "name": "John Doe"}
316324
```
317325

318-
<h2></h2>
326+
</td></tr>
327+
<tr></tr>
328+
<tr><td valign="top"><code>X-Content-Source</code></td>
329+
<td>
330+
<p>
331+
The URL of the externally hosted content. The content from the URL will be sent as the response body.
332+
Supported protocols: <code>http:</code>, <code>https:</code>, <code>file:</code>, <code>data:</code>.<br>
333+
If the URL provides its own content type and there is no <code>Content-Type</code> header in the dump, the original <code>Content-Type</code> header received from the URL will be sent along with other response headers.
334+
</p>
335+
<p>
336+
This header is useful when you want to send content hosted on a remote server or just send binary data as a response body.
337+
</p>
338+
<i>Examples:</i>
339+
<br><br>
319340

320341
Get a response body from a remote server.<br>
321-
Body type is <code>text/uri-list</code> (RFC 2483)
322342

323343
```http
324344
HTTP/1.1 200 OK
325345
Content-Type: application/json
326-
X-Body-Type: text/uri-list
327-
328-
http://example.com/api/car/1234.json
346+
X-Content-Source: http://example.com/api/car/1234.json
329347
```
330348

331349
<h2></h2>
332350

333351
Get a response body from a file.<br>
334-
Body type is <code>text/uri-list</code> (RFC 2483)
335352

336353
```http
337354
HTTP/1.1 200 OK
338355
Content-Type: image/jpeg
339-
X-Body-Type: text/uri-list
340-
341-
file:///home/john/photo.jpeg
356+
X-Content-Source: file:///home/john/photo.jpeg
342357
```
343358

344359
<h2></h2>
345360

346361
Get a response body from a data URI.<br>
347-
Body type is <code>text/uri-list</code> (RFC 2483)
348362

349363
```http
350364
HTTP/1.1 200 OK
351365
Content-Type: image/gif
352-
X-Body-Type: text/uri-list
353-
354-
data:image/gif;base64,R0lGODlhAQABAIAAAP...
355-
```
356-
</td></tr>
357-
<tr></tr>
358-
<tr><td valign="top"><code>X-Request-Delay</code></td>
359-
<td><p>Request delay (in milliseconds).</p>
360-
<i>Example:</i>
361-
<br>
362-
363-
```http
364-
# Two seconds request delay.
365-
366-
HTTP/1.1 200 OK
367-
X-Request-Delay: 2000
368-
369-
{"id": 5, "name": "John Doe"}
366+
X-Content-Source: data:image/gif;base64,R0lGODlhAQABAIAAAP...
370367
```
371368
</td></tr>
372369
<tr></tr>
373-
<tr><td valign="top"><code>X-Response-Delay</code></td>
374-
<td><p>Response delay (in milliseconds).</p>
370+
<tr><td valign="top"><code>X-CGI</code></td>
371+
<td>
372+
<p>CGI (Common Gateway Interface) program.</p>
375373
<i>Example:</i>
376-
<br>
374+
<br>
377375

378376
```http
379-
# Two seconds response delay.
380-
381-
HTTP/1.1 200 OK
382-
X-Response-Delay: 2000
383-
384-
{"id": 5, "name": "John Doe"}
377+
HTTP/1.1 000
378+
X-CGI: /home/john/myprog.sh param1 param2
385379
```
386380
<img width="1000" height="0">
387-
</td></tr>
381+
</td>
382+
</td></tr>
388383
</table>
389384
<strong>NOTE: </strong>Optional response headers will <strong>not</strong> be sent to clients.
390385
<br><br>

build-DeepfakeHTTP.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ E-Mail: xnbox.team@outlook.com
3636

3737
<target name="main">
3838
<property name="dollar" value="$" />
39-
<property name="build.version" value="3.2.1" />
39+
<property name="build.version" value="4.1.1" />
4040
<property name="tmpDir" value="${java.io.tmpdir}" />
4141
<property name="tmpAppWar" value="${tmpDir}/app.war" />
4242
<property name="tmpMetaInfDir" value="${tmpDir}/DeepfakeHTTP/META-INF" />

0 commit comments

Comments
 (0)