Skip to content

Commit 39945f2

Browse files
committed
Add constructors to HTTP classes
1 parent fcb690f commit 39945f2

File tree

4 files changed

+37
-71
lines changed

4 files changed

+37
-71
lines changed

0.10/node.d.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ declare module "http" {
424424
}
425425

426426
export class Server extends events.EventEmitter {
427+
constructor(req: IncomingMessage, res: ServerResponse);
427428
listen(port: number, hostname?: string, backlog?: number, callback?: Function): Server;
428429
listen(path: string, callback?: Function): Server;
429430
listen(handle: any, listeningListener?: Function): Server;
@@ -438,8 +439,6 @@ declare module "http" {
438439
rawHeaders: string[];
439440
trailers: IncomingHeaders;
440441
rawTrailers: string[];
441-
setTimeout(msecs: number, callback?: () => void): this;
442-
destroy(error?: Error): void;
443442
/**
444443
* Only valid for request obtained from http.Server.
445444
*/
@@ -457,13 +456,18 @@ declare module "http" {
457456
*/
458457
statusMessage?: string;
459458
socket: net.Socket;
459+
460+
constructor(socket: net.Socket);
461+
setTimeout(msecs: number, callback?: () => void): this;
462+
destroy(error?: Error): void;
460463
}
461464

462465
export class OutgoingMessage extends stream.Writable {
463466
finished: boolean;
464467
sendDate: boolean;
465468
headersSent: boolean;
466469

470+
constructor();
467471
setTimeout(msecs: number, callback?: () => void): this;
468472
setHeader(name: string, value: number | string | string[]): void;
469473
getHeader(name: string): number | string | string[] | undefined;
@@ -474,6 +478,7 @@ declare module "http" {
474478
export class ServerResponse extends OutgoingMessage {
475479
statusCode: number;
476480

481+
constructor(req: IncomingMessage);
477482
writeContinue(cb?: () => void): void;
478483
writeHead(statusCode: number, statusText?: string, headers?: OutgoingHeaders): void;
479484
writeHead(statusCode: number, headers?: OutgoingHeaders): void;
@@ -485,6 +490,7 @@ declare module "http" {
485490
* Object returned by http.request()
486491
*/
487492
export class ClientRequest extends OutgoingMessage {
493+
constructor(options: string | RequestOptions, cb?: (res: IncomingMessage) => void);
488494
abort(): void;
489495
setNoDelay(noDelay?: boolean): void;
490496
setSocketKeepAlive(enable?: boolean, initialDelay?: number): void;
@@ -1028,18 +1034,10 @@ declare module "net" {
10281034
export class Socket extends stream.Duplex {
10291035
constructor(options?: { fd?: string; type?: string; allowHalfOpen?: boolean; });
10301036

1031-
// Extended base methods
1032-
write(buffer: Buffer): boolean;
1033-
write(buffer: Buffer, cb?: Function): boolean;
1034-
write(str: string, cb?: Function): boolean;
1035-
write(str: string, encoding?: string, cb?: Function): boolean;
1036-
write(str: string, encoding?: string, fd?: string): boolean;
1037-
10381037
connect(port: number, host?: string, connectionListener?: Function): void;
10391038
connect(path: string, connectionListener?: Function): void;
10401039
bufferSize: number;
10411040
setEncoding(encoding?: string): void;
1042-
write(data: any, encoding?: string, callback?: Function): void;
10431041
destroy(): void;
10441042
pause(): void;
10451043
resume(): void;
@@ -1054,13 +1052,6 @@ declare module "net" {
10541052
remotePort: number;
10551053
bytesRead: number;
10561054
bytesWritten: number;
1057-
1058-
// Extended base methods
1059-
end(): void;
1060-
end(buffer: Buffer, cb?: Function): void;
1061-
end(str: string, cb?: Function): void;
1062-
end(str: string, encoding?: string, cb?: Function): void;
1063-
end(data?: any, encoding?: string): void;
10641055
}
10651056

10661057
export class Server extends Socket {

0.12/node.d.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ declare module "http" {
613613
}
614614

615615
export class Server extends events.EventEmitter {
616+
constructor(req: IncomingMessage, res: ServerResponse);
616617
listen(port: number, hostname?: string, backlog?: number, callback?: Function): Server;
617618
listen(port: number, hostname?: string, callback?: Function): Server;
618619
listen(path: string, callback?: Function): Server;
@@ -627,6 +628,7 @@ declare module "http" {
627628
sendDate: boolean;
628629
headersSent: boolean;
629630

631+
constructor();
630632
setTimeout(msecs: number, callback?: () => void): this;
631633
setHeader(name: string, value: number | string | string[]): void;
632634
getHeader(name: string): number | string | string[] | undefined;
@@ -638,6 +640,7 @@ declare module "http" {
638640
statusCode: number;
639641
statusMessage: string;
640642

643+
constructor(req: IncomingMessage);
641644
writeContinue(cb?: () => void): void;
642645
writeHead(statusCode: number, statusText?: string, headers?: OutgoingHeaders): void;
643646
writeHead(statusCode: number, headers?: OutgoingHeaders): void;
@@ -646,6 +649,7 @@ declare module "http" {
646649
}
647650

648651
export class ClientRequest extends OutgoingMessage {
652+
constructor(options: string | RequestOptions, cb?: (res: IncomingMessage) => void);
649653
abort(): void;
650654
setNoDelay(noDelay?: boolean): void;
651655
setSocketKeepAlive(enable?: boolean, initialDelay?: number): void;
@@ -657,8 +661,6 @@ declare module "http" {
657661
rawHeaders: string[];
658662
trailers: IncomingHeaders;
659663
rawTrailers: string[];
660-
setTimeout(msecs: number, callback: () => void): this;
661-
destroy(error?: Error): void;
662664
/**
663665
* Only valid for request obtained from http.Server.
664666
*/
@@ -676,6 +678,11 @@ declare module "http" {
676678
*/
677679
statusMessage?: string;
678680
socket: net.Socket;
681+
connection: net.Socket;
682+
683+
constructor(socket: net.Socket);
684+
setTimeout(msecs: number, callback: () => void): this;
685+
destroy(error?: Error): void;
679686
}
680687

681688
export interface AgentOptions {
@@ -1271,17 +1278,9 @@ declare module "net" {
12711278
export class Socket extends stream.Duplex {
12721279
constructor(options?: { fd?: string; type?: string; allowHalfOpen?: boolean; });
12731280

1274-
// Extended base methods
1275-
write(buffer: Buffer): boolean;
1276-
write(buffer: Buffer, cb?: Function): boolean;
1277-
write(str: string, cb?: Function): boolean;
1278-
write(str: string, encoding?: string, cb?: Function): boolean;
1279-
write(str: string, encoding?: string, fd?: string): boolean;
1280-
12811281
connect(port: number, host?: string, connectionListener?: Function): void;
12821282
connect(path: string, connectionListener?: Function): void;
12831283
bufferSize: number;
1284-
write(data: any, encoding?: string, callback?: Function): void;
12851284
destroy(): void;
12861285
setTimeout(timeout: number, callback?: Function): void;
12871286
setNoDelay(noDelay?: boolean): void;
@@ -1297,13 +1296,6 @@ declare module "net" {
12971296
localPort: number;
12981297
bytesRead: number;
12991298
bytesWritten: number;
1300-
1301-
// Extended base methods
1302-
end(): void;
1303-
end(buffer: Buffer, cb?: Function): void;
1304-
end(str: string, cb?: Function): void;
1305-
end(str: string, encoding?: string, cb?: Function): void;
1306-
end(data?: any, encoding?: string): void;
13071299
}
13081300

13091301
export class Server extends Socket {

4.0/node.d.ts

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,8 @@ declare module "http" {
745745
}
746746

747747
export class Server extends net.Server {
748-
setTimeout(msecs: number, callback: Function): void;
748+
constructor(req: IncomingMessage, res: ServerResponse);
749+
setTimeout(msecs: number, callback?: () => void): void;
749750
maxHeadersCount: number;
750751
timeout: number;
751752
}
@@ -755,6 +756,7 @@ declare module "http" {
755756
sendDate: boolean;
756757
headersSent: boolean;
757758

759+
constructor();
758760
setTimeout(msecs: number, callback?: () => void): this;
759761
setHeader(name: string, value: number | string | string[]): void;
760762
getHeader(name: string): number | string | string[] | undefined;
@@ -766,6 +768,7 @@ declare module "http" {
766768
statusCode: number;
767769
statusMessage: string;
768770

771+
constructor(req: IncomingMessage);
769772
writeContinue(cb?: () => void): void;
770773
writeHead(statusCode: number, statusText?: string, headers?: OutgoingHeaders): void;
771774
writeHead(statusCode: number, headers?: OutgoingHeaders): void;
@@ -774,6 +777,7 @@ declare module "http" {
774777
}
775778

776779
export class ClientRequest extends OutgoingMessage {
780+
constructor(options: string | RequestOptions, cb?: (res: IncomingMessage) => void);
777781
abort(): void;
778782
setNoDelay(noDelay?: boolean): void;
779783
setSocketKeepAlive(enable?: boolean, initialDelay?: number): void;
@@ -787,8 +791,6 @@ declare module "http" {
787791
rawHeaders: string[];
788792
trailers: IncomingHeaders;
789793
rawTrailers: string[];
790-
setTimeout(msecs: number, callback: () => void): this;
791-
destroy(error?: Error): void;
792794
/**
793795
* Only valid for request obtained from http.Server.
794796
*/
@@ -806,6 +808,11 @@ declare module "http" {
806808
*/
807809
statusMessage?: string;
808810
socket: net.Socket;
811+
connection: net.Socket;
812+
813+
constructor(socket: net.Socket);
814+
setTimeout(msecs: number, callback: () => void): this;
815+
destroy(error?: Error): void;
809816
}
810817

811818
export interface AgentOptions {
@@ -1464,19 +1471,11 @@ declare module "net" {
14641471
export class Socket extends stream.Duplex {
14651472
constructor(options?: { fd?: string; type?: string; allowHalfOpen?: boolean; });
14661473

1467-
// Extended base methods
1468-
write(buffer: Buffer): boolean;
1469-
write(buffer: Buffer, cb?: Function): boolean;
1470-
write(str: string, cb?: Function): boolean;
1471-
write(str: string, encoding?: string, cb?: Function): boolean;
1472-
write(str: string, encoding?: string, fd?: string): boolean;
1473-
14741474
connect(port: number, host?: string, connectionListener?: Function): void;
14751475
connect(path: string, connectionListener?: Function): void;
14761476
bufferSize: number;
1477-
write(data: any, encoding?: string, callback?: Function): void;
1478-
destroy(): void;
1479-
setTimeout(timeout: number, callback?: Function): void;
1477+
destroy(exception?: Error): void;
1478+
setTimeout(timeout: number, callback?: () => void): void;
14801479
setNoDelay(noDelay?: boolean): void;
14811480
setKeepAlive(enable?: boolean, initialDelay?: number): void;
14821481
address(): { port: number; family: string; address: string; };
@@ -1490,13 +1489,6 @@ declare module "net" {
14901489
localPort: number;
14911490
bytesRead: number;
14921491
bytesWritten: number;
1493-
1494-
// Extended base methods
1495-
end(): void;
1496-
end(buffer: Buffer, cb?: Function): void;
1497-
end(str: string, cb?: Function): void;
1498-
end(str: string, encoding?: string, cb?: Function): void;
1499-
end(data?: any, encoding?: string): void;
15001492
}
15011493

15021494
export interface ListenOptions {

6.0/node.d.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ declare module "http" {
773773
}
774774

775775
export class Server extends net.Server {
776+
constructor(req: IncomingMessage, res: ServerResponse);
776777
setTimeout(msecs: number, callback: Function): void;
777778
maxHeadersCount: number;
778779
timeout: number;
@@ -784,6 +785,7 @@ declare module "http" {
784785
sendDate: boolean;
785786
headersSent: boolean;
786787

788+
constructor();
787789
setTimeout(msecs: number, callback?: () => void): this;
788790
setHeader(name: string, value: number | string | string[]): void;
789791
getHeader(name: string): number | string | string[] | undefined;
@@ -795,6 +797,7 @@ declare module "http" {
795797
statusCode: number;
796798
statusMessage: string;
797799

800+
constructor(req: IncomingMessage);
798801
writeContinue(cb?: () => void): void;
799802
writeHead(statusCode: number, statusText?: string, headers?: OutgoingHeaders): void;
800803
writeHead(statusCode: number, headers?: OutgoingHeaders): void;
@@ -803,6 +806,7 @@ declare module "http" {
803806
}
804807

805808
export class ClientRequest extends OutgoingMessage {
809+
constructor(options: string | RequestOptions, cb?: (res: IncomingMessage) => void);
806810
abort(): void;
807811
setNoDelay(noDelay?: boolean): void;
808812
setSocketKeepAlive(enable?: boolean, initialDelay?: number): void;
@@ -814,8 +818,6 @@ declare module "http" {
814818
rawHeaders: string[];
815819
trailers: IncomingHeaders;
816820
rawTrailers: string[];
817-
setTimeout(msecs: number, callback?: () => void): this;
818-
destroy(error?: Error): void;
819821
/**
820822
* Only valid for request obtained from http.Server.
821823
*/
@@ -833,6 +835,10 @@ declare module "http" {
833835
*/
834836
statusMessage?: string;
835837
socket: net.Socket;
838+
839+
constructor(socket: net.Socket);
840+
setTimeout(msecs: number, callback?: () => void): this;
841+
destroy(error?: Error): void;
836842
}
837843

838844
export interface AgentOptions {
@@ -1507,17 +1513,9 @@ declare module "net" {
15071513
export class Socket extends stream.Duplex {
15081514
constructor(options?: { fd?: string; type?: string; allowHalfOpen?: boolean; });
15091515

1510-
// Extended base methods
1511-
write(buffer: Buffer): boolean;
1512-
write(buffer: Buffer, cb?: Function): boolean;
1513-
write(str: string, cb?: Function): boolean;
1514-
write(str: string, encoding?: string, cb?: Function): boolean;
1515-
write(str: string, encoding?: string, fd?: string): boolean;
1516-
15171516
connect(port: number, host?: string, connectionListener?: Function): void;
15181517
connect(path: string, connectionListener?: Function): void;
15191518
bufferSize: number;
1520-
write(data: any, encoding?: string, callback?: Function): void;
15211519
destroy(): void;
15221520
setTimeout(timeout: number, callback?: Function): void;
15231521
setNoDelay(noDelay?: boolean): void;
@@ -1533,13 +1531,6 @@ declare module "net" {
15331531
localPort: number;
15341532
bytesRead: number;
15351533
bytesWritten: number;
1536-
1537-
// Extended base methods
1538-
end(): void;
1539-
end(buffer: Buffer, cb?: Function): void;
1540-
end(str: string, cb?: Function): void;
1541-
end(str: string, encoding?: string, cb?: Function): void;
1542-
end(data?: any, encoding?: string): void;
15431534
}
15441535

15451536
export interface ListenOptions {

0 commit comments

Comments
 (0)