(maxBytes: number | undefined)
| 829 | } |
| 830 | |
| 831 | private readBytes(maxBytes: number | undefined): Effect.Effect<Uint8Array, HttpServerError> { |
| 832 | const body = this.source.body |
| 833 | switch (body._tag) { |
| 834 | case "Empty": { |
| 835 | return Effect.succeed(new Uint8Array(0)) |
| 836 | } |
| 837 | case "Uint8Array": { |
| 838 | return maxBytes !== undefined && body.body.byteLength > maxBytes |
| 839 | ? Effect.fail(bodyTooLargeError(this, new BodyTooLargeError(maxBytes))) |
| 840 | : Effect.succeed(body.body) |
| 841 | } |
| 842 | case "FormData": { |
| 843 | return bytesFromWeb(this, () => new Response(body.formData), maxBytes) |
| 844 | } |
| 845 | case "Stream": { |
| 846 | return Stream.mkUint8Array(maxBytes === undefined ? this.stream : limitStream(this, this.stream, maxBytes)) |
| 847 | } |
| 848 | case "Raw": { |
| 849 | return rawBodyBytes(this, body.body, maxBytes) |
| 850 | } |
| 851 | } |
| 852 | } |
| 853 | |
| 854 | get text(): Effect.Effect<string, HttpServerError> { |
| 855 | return Effect.map(this.bytes, (bytes) => textDecoder.decode(bytes)) |
no test coverage detected