(event: H3Event, value: unknown, method?: StreamCompression)
| 197 | * @returns { Promise<Response> } |
| 198 | */ |
| 199 | export async function compressResponseStream(event: H3Event, value: unknown, method?: StreamCompression): Promise<Response> { |
| 200 | const response = await ensureToResponse()(value, event) |
| 201 | const compressionMethod = method ?? getStreamCompression(event) |
| 202 | |
| 203 | if (!compressionMethod || !response.body || response.headers.has('Content-Encoding')) |
| 204 | return response |
| 205 | |
| 206 | return cloneResponse(response, response.body.pipeThrough(new CompressionStream(compressionMethod)), compressionMethod) |
| 207 | } |
no test coverage detected