import { IncomingMessage } from 'http'; import { PassThrough } from 'stream'; declare const COPIED_FIELDS: readonly ["statusCode", "statusMessage", "headers", "rawHeaders", "httpVersion", "httpVersionMajor", "httpVersionMinor", "method", "url", "socket", "trailers", "rawTrailers", "complete", "aborted"]; /** Duck-typed stand-in for `IncomingMessage` returned by {@link createResponseTee}. */ type ResponseTee = PassThrough & Pick & { setTimeout?: (msecs: number, callback?: () => void) => ResponseTee; }; /** * Tees an intercepted http/https response into an independent stream for the host callback. * * A raw Node Readable can only have one "true" consumer — whoever attaches a 'data' listener * first switches it into flowing mode and wins the race. Handing the host the raw `res` (while * the interceptor also attaches its own capture listeners) would silently starve a host callback * that consumes the response asynchronously (e.g. after an `await`) or via a deferred `.pipe()`. * The returned stream is untouched until the host reads it, so it buffers correctly regardless * of when that happens — the race is eliminated by construction. * * The interceptor's own capture listeners (`res.on('data'/'end', ...)`) are attached separately * by the caller and are unaffected by this — both sets of listeners receive every chunk. * * Callers should only invoke this when there is actually a host callback to hand the result to * (see `hostIsReading` below for why an unread tee must never apply backpressure) — constructing * one that nobody will ever read is wasted work at best. * * `instanceof http.IncomingMessage` is `false` for the returned tee — it's a real `PassThrough` * with IncomingMessage-shaped metadata copied on, not a real instance of it. */ declare function createResponseTee(res: IncomingMessage, PassThroughCtor: new () => PassThrough): ResponseTee; export { type ResponseTee, createResponseTee };