* Create a `Response` with a `Content-Type: "application/xml"` body. * @example * HttpResponse.xml(` `) * HttpResponse.xml(` `, { status: 201 })
(
body?: BodyType | null,
init?: HttpResponseInit,
)
| 144 | * HttpResponse.xml(`<article id="abc-123" />`, { status: 201 }) |
| 145 | */ |
| 146 | static xml<BodyType extends string>( |
| 147 | body?: BodyType | null, |
| 148 | init?: HttpResponseInit, |
| 149 | ): HttpResponse<BodyType> { |
| 150 | const responseInit = normalizeResponseInit(init) |
| 151 | const hasExplicitContentType = responseInit.headers.has('Content-Type') |
| 152 | |
| 153 | if (!hasExplicitContentType) { |
| 154 | responseInit.headers.set('Content-Type', 'text/xml') |
| 155 | } |
| 156 | |
| 157 | const response = new HttpResponse(body, responseInit) |
| 158 | |
| 159 | if (!hasExplicitContentType) { |
| 160 | Object.defineProperty(response, kDefaultContentType, { |
| 161 | value: true, |
| 162 | enumerable: false, |
| 163 | }) |
| 164 | } |
| 165 | |
| 166 | return response as HttpResponse<BodyType> |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * Create a `Response` with a `Content-Type: "text/html"` body. |
no test coverage detected