| 85 | * @since 4.0.0 |
| 86 | */ |
| 87 | export const make = (fallback: Platform.Compression): Platform.Compression => ({ |
| 88 | algorithms: fallback.algorithms, |
| 89 | compressResponse(response, algorithm, options) { |
| 90 | const body = response.body |
| 91 | if (body._tag !== "Uint8Array") { |
| 92 | return fallback.compressResponse(response, algorithm, options) |
| 93 | } |
| 94 | return Effect.map(compress(body.body, algorithm, options), (result) => |
| 95 | Response.setHeader( |
| 96 | Response.setBody(response, HttpBody.uint8Array(result, body.contentType)), |
| 97 | "content-length", |
| 98 | result.byteLength.toString() |
| 99 | )) |
| 100 | } |
| 101 | }) |
| 102 | |
| 103 | /** |
| 104 | * Creates a `node:zlib` compression transform stream that flushes each input |