| 1199 | ) |
| 1200 | |
| 1201 | class ServerHttpClientResponse extends Inspectable.Class implements HttpClientResponse.HttpClientResponse, Pipeable { |
| 1202 | readonly [HttpIncomingMessage.TypeId]: typeof HttpIncomingMessage.TypeId |
| 1203 | readonly [HttpClientResponse.TypeId]: typeof HttpClientResponse.TypeId |
| 1204 | |
| 1205 | readonly request: HttpClientRequest.HttpClientRequest |
| 1206 | private readonly response: HttpServerResponse |
| 1207 | |
| 1208 | constructor( |
| 1209 | request: HttpClientRequest.HttpClientRequest, |
| 1210 | response: HttpServerResponse |
| 1211 | ) { |
| 1212 | super() |
| 1213 | this.request = request |
| 1214 | this.response = response |
| 1215 | this[HttpIncomingMessage.TypeId] = HttpIncomingMessage.TypeId |
| 1216 | this[HttpClientResponse.TypeId] = HttpClientResponse.TypeId |
| 1217 | } |
| 1218 | |
| 1219 | toJSON(): unknown { |
| 1220 | return HttpIncomingMessage.inspect(this, { |
| 1221 | _id: "HttpClientResponse", |
| 1222 | request: this.request.toJSON(), |
| 1223 | status: this.status |
| 1224 | }) |
| 1225 | } |
| 1226 | |
| 1227 | get status(): number { |
| 1228 | return this.response.status |
| 1229 | } |
| 1230 | |
| 1231 | get url(): string { |
| 1232 | if (this.request === HttpClientRequest.empty) return "" |
| 1233 | const url = HttpClientRequest.toUrl(this.request) |
| 1234 | if (Option.isNone(url)) return "" |
| 1235 | url.value.hash = "" |
| 1236 | return url.value.href |
| 1237 | } |
| 1238 | |
| 1239 | private cachedHeaders?: Headers.Headers |
| 1240 | get headers(): Headers.Headers { |
| 1241 | return this.cachedHeaders ??= this.response.body._tag === "FormData" |
| 1242 | ? Headers.merge(this.response.headers, Headers.fromInput(this.getFormDataResponse().headers)) |
| 1243 | : this.response.headers |
| 1244 | } |
| 1245 | |
| 1246 | get cookies(): Cookies.Cookies { |
| 1247 | return this.response.cookies |
| 1248 | } |
| 1249 | |
| 1250 | get remoteAddress(): Option.Option<string> { |
| 1251 | return Option.none() |
| 1252 | } |
| 1253 | |
| 1254 | get stream(): Stream.Stream<Uint8Array, HttpClientError.HttpClientError> { |
| 1255 | const body = this.response.body |
| 1256 | switch (body._tag) { |
| 1257 | case "Empty": { |
| 1258 | return Stream.empty |
nothing calls this directly
no outgoing calls
no test coverage detected