1 | import { StreamResponse, BufferedStreamResponse } from '@worker-tools/stream-response';
|
2 | const CONTENT_TYPE = 'Content-Type';
|
3 |
|
4 |
|
5 |
|
6 | export class HTMLResponse extends StreamResponse {
|
7 | constructor(html, { headers: _headers, ...init } = {}) {
|
8 | const headers = new Headers(_headers);
|
9 | if (!headers.has(CONTENT_TYPE))
|
10 | headers.set(CONTENT_TYPE, HTMLResponse.contentType);
|
11 | super(html, { headers, ...init });
|
12 | }
|
13 | }
|
14 | Object.defineProperty(HTMLResponse, "contentType", {
|
15 | enumerable: true,
|
16 | configurable: true,
|
17 | writable: true,
|
18 | value: 'text/html;charset=UTF-8'
|
19 | });
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | export class BufferedHTMLResponse extends BufferedStreamResponse {
|
26 | constructor(html, { headers: _headers, ...init } = {}) {
|
27 | const headers = new Headers(_headers);
|
28 | if (!headers.has(CONTENT_TYPE))
|
29 | headers.set(CONTENT_TYPE, BufferedHTMLResponse.contentType);
|
30 | super(html, { headers, ...init });
|
31 | }
|
32 | }
|
33 | Object.defineProperty(BufferedHTMLResponse, "contentType", {
|
34 | enumerable: true,
|
35 | configurable: true,
|
36 | writable: true,
|
37 | value: 'text/html;charset=UTF-8'
|
38 | });
|
39 |
|
\ | No newline at end of file |