| | |
| | | * 'Host', 'mysite.com', |
| | | * 'accepT', '*' ] |
| | | * ``` |
| | | * @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/http.js) |
| | | * @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/http.js) |
| | | */ |
| | | declare module 'http' { |
| | | import * as stream from 'node:stream'; |
| | | import { URL } from 'node:url'; |
| | | import { Socket, Server as NetServer } from 'node:net'; |
| | | import { TcpSocketConnectOpts, Socket, Server as NetServer, LookupFunction } from 'node:net'; |
| | | // incoming headers will never contain number |
| | | interface IncomingHttpHeaders extends NodeJS.Dict<string | string[]> { |
| | | accept?: string | undefined; |
| | |
| | | type OutgoingHttpHeader = number | string | string[]; |
| | | interface OutgoingHttpHeaders extends NodeJS.Dict<OutgoingHttpHeader> {} |
| | | interface ClientRequestArgs { |
| | | abort?: AbortSignal | undefined; |
| | | signal?: AbortSignal | undefined; |
| | | protocol?: string | null | undefined; |
| | | host?: string | null | undefined; |
| | | hostname?: string | null | undefined; |
| | |
| | | setHost?: boolean | undefined; |
| | | // https://github.com/nodejs/node/blob/master/lib/_http_client.js#L278 |
| | | createConnection?: ((options: ClientRequestArgs, oncreate: (err: Error, socket: Socket) => void) => Socket) | undefined; |
| | | lookup?: LookupFunction | undefined; |
| | | } |
| | | interface ServerOptions { |
| | | IncomingMessage?: typeof IncomingMessage | undefined; |
| | |
| | | /** |
| | | * Aliases of `outgoingMessage.socket` |
| | | * @since v0.3.0 |
| | | * @deprecated Since v15.12.0 - Use `socket` instead. |
| | | * @deprecated Since v15.12.0,v14.17.1 - Use `socket` instead. |
| | | */ |
| | | readonly connection: Socket | null; |
| | | /** |
| | |
| | | * The `request.aborted` property will be `true` if the request has |
| | | * been aborted. |
| | | * @since v0.11.14 |
| | | * @deprecated Since v17.0.0 - Check `destroyed` instead. |
| | | */ |
| | | aborted: boolean; |
| | | /** |
| | |
| | | * @since v14.5.0, v12.19.0 |
| | | */ |
| | | protocol: string; |
| | | /** |
| | | * Whether the request is send through a reused socket. |
| | | * @since v13.0.0, v12.16.0 |
| | | */ |
| | | reusedSocket: boolean; |
| | | /** |
| | | * Limits maximum response headers count. If set to 0, no limit will be applied. |
| | | * @default 2000 |
| | | */ |
| | | maxHeadersCount: number; |
| | | constructor(url: string | URL | ClientRequestArgs, cb?: (res: IncomingMessage) => void); |
| | | /** |
| | | * The request method. |
| | |
| | | * const headerNames = request.getRawHeaderNames(); |
| | | * // headerNames === ['Foo', 'Set-Cookie'] |
| | | * ``` |
| | | * @since v15.13.0 |
| | | * @since v15.13.0, v14.17.0 |
| | | */ |
| | | getRawHeaderNames(): string[]; |
| | | /** |
| | | * @deprecated |
| | | */ |
| | | addListener(event: 'abort', listener: () => void): this; |
| | | addListener(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; |
| | | addListener(event: 'continue', listener: () => void): this; |
| | |
| | | addListener(event: 'pipe', listener: (src: stream.Readable) => void): this; |
| | | addListener(event: 'unpipe', listener: (src: stream.Readable) => void): this; |
| | | addListener(event: string | symbol, listener: (...args: any[]) => void): this; |
| | | /** |
| | | * @deprecated |
| | | */ |
| | | on(event: 'abort', listener: () => void): this; |
| | | on(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; |
| | | on(event: 'continue', listener: () => void): this; |
| | |
| | | on(event: 'pipe', listener: (src: stream.Readable) => void): this; |
| | | on(event: 'unpipe', listener: (src: stream.Readable) => void): this; |
| | | on(event: string | symbol, listener: (...args: any[]) => void): this; |
| | | /** |
| | | * @deprecated |
| | | */ |
| | | once(event: 'abort', listener: () => void): this; |
| | | once(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; |
| | | once(event: 'continue', listener: () => void): this; |
| | |
| | | once(event: 'pipe', listener: (src: stream.Readable) => void): this; |
| | | once(event: 'unpipe', listener: (src: stream.Readable) => void): this; |
| | | once(event: string | symbol, listener: (...args: any[]) => void): this; |
| | | /** |
| | | * @deprecated |
| | | */ |
| | | prependListener(event: 'abort', listener: () => void): this; |
| | | prependListener(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; |
| | | prependListener(event: 'continue', listener: () => void): this; |
| | |
| | | prependListener(event: 'pipe', listener: (src: stream.Readable) => void): this; |
| | | prependListener(event: 'unpipe', listener: (src: stream.Readable) => void): this; |
| | | prependListener(event: string | symbol, listener: (...args: any[]) => void): this; |
| | | /** |
| | | * @deprecated |
| | | */ |
| | | prependOnceListener(event: 'abort', listener: () => void): this; |
| | | prependOnceListener(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; |
| | | prependOnceListener(event: 'continue', listener: () => void): this; |
| | |
| | | * The `message.aborted` property will be `true` if the request has |
| | | * been aborted. |
| | | * @since v10.1.0 |
| | | * @deprecated Since v17.0.0 - Check `message.destroyed` from [stream.Readable](https://nodejs.org/dist/latest-v17.x/docs/api/stream.html#class-streamreadable). |
| | | */ |
| | | aborted: boolean; |
| | | /** |
| | |
| | | * as an argument to any listeners on the event. |
| | | * @since v0.3.0 |
| | | */ |
| | | destroy(error?: Error): void; |
| | | destroy(error?: Error): this; |
| | | } |
| | | interface AgentOptions { |
| | | interface AgentOptions extends Partial<TcpSocketConnectOpts> { |
| | | /** |
| | | * Keep sockets around in a pool to be used by other requests in the future. Default = false |
| | | */ |