1 | import { StreamResponse, BufferedStreamResponse } from '@worker-tools/stream-response';
|
2 | import { HTML } from './html.js';
|
3 |
|
4 | const CONTENT_TYPE = 'Content-Type'
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | export class HTMLResponse extends StreamResponse {
|
10 | static contentType = 'text/html;charset=UTF-8';
|
11 |
|
12 | constructor(html: HTML, { headers: _headers, ...init }: ResponseInit = {}) {
|
13 | const headers = new Headers(_headers);
|
14 | if (!headers.has(CONTENT_TYPE)) headers.set(CONTENT_TYPE, HTMLResponse.contentType);
|
15 | super(html, { headers, ...init });
|
16 | }
|
17 | }
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | export class BufferedHTMLResponse extends BufferedStreamResponse {
|
25 | static contentType = 'text/html;charset=UTF-8';
|
26 |
|
27 | constructor(html: HTML, { headers: _headers, ...init }: ResponseInit = {}) {
|
28 | const headers = new Headers(_headers);
|
29 | if (!headers.has(CONTENT_TYPE)) headers.set(CONTENT_TYPE, BufferedHTMLResponse.contentType);
|
30 | super(html, { headers, ...init });
|
31 | }
|
32 | }
|