(self: HttpIncomingMessage<E>, that: object)
| 123 | * @since 4.0.0 |
| 124 | */ |
| 125 | export const inspect = <E>(self: HttpIncomingMessage<E>, that: object): object => { |
| 126 | const contentType = self.headers["content-type"] ?? "" |
| 127 | let body: unknown |
| 128 | if (contentType.includes("application/json")) { |
| 129 | try { |
| 130 | body = Effect.runSync(self.json) |
| 131 | // oxlint-disable-next-line @typescript-eslint/no-unused-vars |
| 132 | } catch (_) { |
| 133 | // |
| 134 | } |
| 135 | } else if (contentType.includes("text/") || contentType.includes("urlencoded")) { |
| 136 | try { |
| 137 | body = Effect.runSync(self.text) |
| 138 | // oxlint-disable-next-line @typescript-eslint/no-unused-vars |
| 139 | } catch (_) { |
| 140 | // |
| 141 | } |
| 142 | } |
| 143 | const obj: any = { |
| 144 | ...that, |
| 145 | headers: redact(self.headers), |
| 146 | remoteAddress: self.remoteAddress |
| 147 | } |
| 148 | if (body !== undefined) { |
| 149 | obj.body = body |
| 150 | } |
| 151 | return obj |
| 152 | } |
no test coverage detected