mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
[node] Update older node types (7,6,4) for more consistency with 8
* Specifically add interfaces for reqeust headers * Make the naming of client request options consistent (ClientRequestArgs)
This commit is contained in:
37
types/node/v4/index.d.ts
vendored
37
types/node/v4/index.d.ts
vendored
@@ -565,19 +565,30 @@ declare module "http" {
|
||||
import * as net from "net";
|
||||
import * as stream from "stream";
|
||||
|
||||
export interface RequestOptions {
|
||||
// incoming headers will never contain number
|
||||
export interface IncomingHttpHeaders {
|
||||
[header: string]: string | string[];
|
||||
}
|
||||
|
||||
// outgoing headers allows numbers (as they are converted internally to strings)
|
||||
export interface OutgoingHttpHeaders {
|
||||
[header: string]: number | string | string[] | undefined;
|
||||
}
|
||||
|
||||
export interface ClientRequestArgs {
|
||||
protocol?: string;
|
||||
host?: string;
|
||||
hostname?: string;
|
||||
family?: number;
|
||||
port?: number;
|
||||
port?: number | string;
|
||||
localAddress?: string;
|
||||
socketPath?: string;
|
||||
method?: string;
|
||||
path?: string;
|
||||
headers?: { [key: string]: any };
|
||||
headers?: OutgoingHttpHeaders;
|
||||
auth?: string;
|
||||
agent?: Agent|boolean;
|
||||
agent?: Agent | boolean;
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
export interface Server extends net.Server {
|
||||
@@ -600,8 +611,8 @@ declare module "http" {
|
||||
write(str: string, encoding?: string, fd?: string): boolean;
|
||||
|
||||
writeContinue(): void;
|
||||
writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void;
|
||||
writeHead(statusCode: number, headers?: any): void;
|
||||
writeHead(statusCode: number, reasonPhrase?: string, headers?: OutgoingHttpHeaders): void;
|
||||
writeHead(statusCode: number, headers?: OutgoingHttpHeaders): void;
|
||||
statusCode: number;
|
||||
statusMessage: string;
|
||||
headersSent: boolean;
|
||||
@@ -610,7 +621,7 @@ declare module "http" {
|
||||
getHeader(name: string): string;
|
||||
removeHeader(name: string): void;
|
||||
write(chunk: any, encoding?: string): any;
|
||||
addTrailers(headers: any): void;
|
||||
addTrailers(headers: OutgoingHttpHeaders): void;
|
||||
|
||||
// Extended base methods
|
||||
end(): void;
|
||||
@@ -636,7 +647,7 @@ declare module "http" {
|
||||
setHeader(name: string, value: string | string[]): void;
|
||||
getHeader(name: string): string;
|
||||
removeHeader(name: string): void;
|
||||
addTrailers(headers: any): void;
|
||||
addTrailers(headers: OutgoingHttpHeaders): void;
|
||||
|
||||
// Extended base methods
|
||||
end(): void;
|
||||
@@ -647,10 +658,10 @@ declare module "http" {
|
||||
}
|
||||
export interface IncomingMessage extends events.EventEmitter, stream.Readable {
|
||||
httpVersion: string;
|
||||
headers: any;
|
||||
headers: IncomingHttpHeaders;
|
||||
rawHeaders: string[];
|
||||
trailers: any;
|
||||
rawTrailers: any;
|
||||
trailers: OutgoingHttpHeaders;
|
||||
rawTrailers: string[];
|
||||
setTimeout(msecs: number, callback: Function): NodeJS.Timer;
|
||||
/**
|
||||
* Only valid for request obtained from http.Server.
|
||||
@@ -720,7 +731,7 @@ declare module "http" {
|
||||
};
|
||||
export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) =>void ): Server;
|
||||
export function createClient(port?: number, host?: string): any;
|
||||
export function request(options: RequestOptions | string, callback?: (res: IncomingMessage) => void): ClientRequest;
|
||||
export function request(options: ClientRequestArgs | string, callback?: (res: IncomingMessage) => void): ClientRequest;
|
||||
export function get(options: any, callback?: (res: IncomingMessage) => void): ClientRequest;
|
||||
export var globalAgent: Agent;
|
||||
}
|
||||
@@ -916,7 +927,7 @@ declare module "https" {
|
||||
SNICallback?: (servername: string) => any;
|
||||
}
|
||||
|
||||
export interface RequestOptions extends http.RequestOptions {
|
||||
export interface RequestOptions extends http.ClientRequestArgs {
|
||||
pfx?: any;
|
||||
key?: any;
|
||||
passphrase?: string;
|
||||
|
||||
35
types/node/v6/index.d.ts
vendored
35
types/node/v6/index.d.ts
vendored
@@ -637,19 +637,30 @@ declare module "http" {
|
||||
import * as net from "net";
|
||||
import * as stream from "stream";
|
||||
|
||||
export interface RequestOptions {
|
||||
// incoming headers will never contain number
|
||||
export interface IncomingHttpHeaders {
|
||||
[header: string]: string | string[];
|
||||
}
|
||||
|
||||
// outgoing headers allows numbers (as they are converted internally to strings)
|
||||
export interface OutgoingHttpHeaders {
|
||||
[header: string]: number | string | string[] | undefined;
|
||||
}
|
||||
|
||||
export interface ClientRequestArgs {
|
||||
protocol?: string;
|
||||
host?: string;
|
||||
hostname?: string;
|
||||
family?: number;
|
||||
port?: number;
|
||||
port?: number | string;
|
||||
localAddress?: string;
|
||||
socketPath?: string;
|
||||
method?: string;
|
||||
path?: string;
|
||||
headers?: { [key: string]: any };
|
||||
headers?: OutgoingHttpHeaders;
|
||||
auth?: string;
|
||||
agent?: Agent | boolean;
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
export interface Server extends net.Server {
|
||||
@@ -673,8 +684,8 @@ declare module "http" {
|
||||
write(str: string, encoding?: string, fd?: string): boolean;
|
||||
|
||||
writeContinue(): void;
|
||||
writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void;
|
||||
writeHead(statusCode: number, headers?: any): void;
|
||||
writeHead(statusCode: number, reasonPhrase?: string, headers?: OutgoingHttpHeaders): void;
|
||||
writeHead(statusCode: number, headers?: OutgoingHttpHeaders): void;
|
||||
statusCode: number;
|
||||
statusMessage: string;
|
||||
headersSent: boolean;
|
||||
@@ -684,7 +695,7 @@ declare module "http" {
|
||||
getHeader(name: string): string;
|
||||
removeHeader(name: string): void;
|
||||
write(chunk: any, encoding?: string): any;
|
||||
addTrailers(headers: any): void;
|
||||
addTrailers(headers: OutgoingHttpHeaders): void;
|
||||
finished: boolean;
|
||||
|
||||
// Extended base methods
|
||||
@@ -711,7 +722,7 @@ declare module "http" {
|
||||
setHeader(name: string, value: string | string[]): void;
|
||||
getHeader(name: string): string;
|
||||
removeHeader(name: string): void;
|
||||
addTrailers(headers: any): void;
|
||||
addTrailers(headers: OutgoingHttpHeaders): void;
|
||||
|
||||
// Extended base methods
|
||||
end(): void;
|
||||
@@ -725,10 +736,10 @@ declare module "http" {
|
||||
httpVersionMajor: number;
|
||||
httpVersionMinor: number;
|
||||
connection: net.Socket;
|
||||
headers: any;
|
||||
headers: IncomingHttpHeaders;
|
||||
rawHeaders: string[];
|
||||
trailers: any;
|
||||
rawTrailers: any;
|
||||
trailers: OutgoingHttpHeaders;
|
||||
rawTrailers: string[];
|
||||
setTimeout(msecs: number, callback: Function): NodeJS.Timer;
|
||||
/**
|
||||
* Only valid for request obtained from http.Server.
|
||||
@@ -798,7 +809,7 @@ declare module "http" {
|
||||
};
|
||||
export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) => void): Server;
|
||||
export function createClient(port?: number, host?: string): any;
|
||||
export function request(options: RequestOptions | string, callback?: (res: IncomingMessage) => void): ClientRequest;
|
||||
export function request(options: ClientRequestArgs | string, callback?: (res: IncomingMessage) => void): ClientRequest;
|
||||
export function get(options: any, callback?: (res: IncomingMessage) => void): ClientRequest;
|
||||
export var globalAgent: Agent;
|
||||
}
|
||||
@@ -1323,7 +1334,7 @@ declare module "https" {
|
||||
SNICallback?: (servername: string, cb: (err: Error, ctx: tls.SecureContext) => any) => any;
|
||||
}
|
||||
|
||||
export interface RequestOptions extends http.RequestOptions {
|
||||
export interface RequestOptions extends http.ClientRequestArgs {
|
||||
pfx?: any;
|
||||
key?: any;
|
||||
passphrase?: string;
|
||||
|
||||
34
types/node/v7/index.d.ts
vendored
34
types/node/v7/index.d.ts
vendored
@@ -654,17 +654,27 @@ declare module "http" {
|
||||
import * as net from "net";
|
||||
import * as stream from "stream";
|
||||
|
||||
export interface RequestOptions {
|
||||
// incoming headers will never contain number
|
||||
export interface IncomingHttpHeaders {
|
||||
[header: string]: string | string[];
|
||||
}
|
||||
|
||||
// outgoing headers allows numbers (as they are converted internally to strings)
|
||||
export interface OutgoingHttpHeaders {
|
||||
[header: string]: number | string | string[] | undefined;
|
||||
}
|
||||
|
||||
export interface ClientRequestArgs {
|
||||
protocol?: string;
|
||||
host?: string;
|
||||
hostname?: string;
|
||||
family?: number;
|
||||
port?: number;
|
||||
port?: number | string;
|
||||
localAddress?: string;
|
||||
socketPath?: string;
|
||||
method?: string;
|
||||
path?: string;
|
||||
headers?: { [key: string]: any };
|
||||
headers?: OutgoingHttpHeaders;
|
||||
auth?: string;
|
||||
agent?: Agent | boolean;
|
||||
timeout?: number;
|
||||
@@ -691,8 +701,8 @@ declare module "http" {
|
||||
write(str: string, encoding?: string, fd?: string): boolean;
|
||||
|
||||
writeContinue(): void;
|
||||
writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void;
|
||||
writeHead(statusCode: number, headers?: any): void;
|
||||
writeHead(statusCode: number, reasonPhrase?: string, headers?: OutgoingHttpHeaders): void;
|
||||
writeHead(statusCode: number, headers?: OutgoingHttpHeaders): void;
|
||||
statusCode: number;
|
||||
statusMessage: string;
|
||||
headersSent: boolean;
|
||||
@@ -702,7 +712,7 @@ declare module "http" {
|
||||
getHeader(name: string): string;
|
||||
removeHeader(name: string): void;
|
||||
write(chunk: any, encoding?: string): any;
|
||||
addTrailers(headers: any): void;
|
||||
addTrailers(headers: OutgoingHttpHeaders): void;
|
||||
finished: boolean;
|
||||
|
||||
// Extended base methods
|
||||
@@ -729,7 +739,7 @@ declare module "http" {
|
||||
setHeader(name: string, value: string | string[]): void;
|
||||
getHeader(name: string): string;
|
||||
removeHeader(name: string): void;
|
||||
addTrailers(headers: any): void;
|
||||
addTrailers(headers: OutgoingHttpHeaders): void;
|
||||
|
||||
// Extended base methods
|
||||
end(): void;
|
||||
@@ -743,10 +753,10 @@ declare module "http" {
|
||||
httpVersionMajor: number;
|
||||
httpVersionMinor: number;
|
||||
connection: net.Socket;
|
||||
headers: any;
|
||||
headers: IncomingHttpHeaders;
|
||||
rawHeaders: string[];
|
||||
trailers: any;
|
||||
rawTrailers: any;
|
||||
trailers: OutgoingHttpHeaders;
|
||||
rawTrailers: string[];
|
||||
setTimeout(msecs: number, callback: Function): NodeJS.Timer;
|
||||
/**
|
||||
* Only valid for request obtained from http.Server.
|
||||
@@ -816,7 +826,7 @@ declare module "http" {
|
||||
};
|
||||
export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) => void): Server;
|
||||
export function createClient(port?: number, host?: string): any;
|
||||
export function request(options: RequestOptions | string, callback?: (res: IncomingMessage) => void): ClientRequest;
|
||||
export function request(options: ClientRequestArgs | string, callback?: (res: IncomingMessage) => void): ClientRequest;
|
||||
export function get(options: any, callback?: (res: IncomingMessage) => void): ClientRequest;
|
||||
export var globalAgent: Agent;
|
||||
}
|
||||
@@ -1389,7 +1399,7 @@ declare module "https" {
|
||||
SNICallback?: (servername: string, cb: (err: Error, ctx: tls.SecureContext) => any) => any;
|
||||
}
|
||||
|
||||
export interface RequestOptions extends http.RequestOptions {
|
||||
export interface RequestOptions extends http.ClientRequestArgs {
|
||||
pfx?: any;
|
||||
key?: any;
|
||||
passphrase?: string;
|
||||
|
||||
@@ -1033,7 +1033,7 @@ namespace http_tests {
|
||||
request.abort();
|
||||
}
|
||||
|
||||
const options: http.RequestOptions = {
|
||||
const options: http.ClientRequestArgs = {
|
||||
timeout: 30000
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user