* Create a `Response` with a `Content-Type: "text/html"` body. * @example * HttpResponse.html(` Jane Doe `) * HttpResponse.html(` Main text `, { status: 201 })
(
body?: BodyType | null,
init?: HttpResponseInit,
)
| 173 | * HttpResponse.html(`<main id="abc-123">Main text</main>`, { status: 201 }) |
| 174 | */ |
| 175 | static html<BodyType extends string>( |
| 176 | body?: BodyType | null, |
| 177 | init?: HttpResponseInit, |
| 178 | ): HttpResponse<BodyType> { |
| 179 | const responseInit = normalizeResponseInit(init) |
| 180 | const hasExplicitContentType = responseInit.headers.has('Content-Type') |
| 181 | |
| 182 | if (!hasExplicitContentType) { |
| 183 | responseInit.headers.set('Content-Type', 'text/html') |
| 184 | } |
| 185 | |
| 186 | const response = new HttpResponse(body, responseInit) |
| 187 | |
| 188 | if (!hasExplicitContentType) { |
| 189 | Object.defineProperty(response, kDefaultContentType, { |
| 190 | value: true, |
| 191 | enumerable: false, |
| 192 | }) |
| 193 | } |
| 194 | |
| 195 | return response as HttpResponse<BodyType> |
| 196 | } |
| 197 | |
| 198 | /** |
| 199 | * Create a `Response` with an `ArrayBuffer` body. |
no test coverage detected