/** * @file Read a raw Node `IncomingMessage` into our `HttpResponse` shape. Split * out of `http-request/request.ts` for size hygiene. Useful when a caller * already has an `IncomingMessage` from code that bypasses `httpRequest()` * (e.g., multipart uploads via `http.request()` directly, or third-party HTTP * libraries) and wants the same fetch-like body accessors. The body is * transparently decompressed when the response carries a `Content-Encoding` * of `gzip` or `br` — the two encodings `httpRequest` advertises via * `Accept-Encoding`. Node's http client does not decompress on its own, so * without this step a compressed Socket API response would reach callers as * raw deflated bytes and fail JSON parsing. */ import type { IncomingResponse } from './request-types.js'; import type { HttpResponse } from './response-types.js'; /** * Decompress a response body per its `Content-Encoding`. Returns the input * unchanged for `identity` or any unrecognized/absent encoding — we only * decompress what `httpRequest` advertised support for (`gzip`, `br`). */ export declare function decodeBody(body: Buffer, contentEncoding: string | string[] | undefined): Promise; /** * Read and buffer a client-side IncomingResponse into an HttpResponse. * * Useful when you have a raw response from code that bypasses `httpRequest()` * (e.g., multipart form-data uploads via `http.request()`, or responses from * third-party HTTP libraries) and need to convert it into the standard * HttpResponse interface. * * @example * ;```typescript * const raw = await makeRawRequest('https://example.com/api') * const response = await readIncomingResponse(raw) * console.log(response.status, response.body.toString('utf8')) * ``` */ export declare function readIncomingResponse(msg: IncomingResponse): Promise;