1
1
import http = require( "http" ) ;
2
2
import type { Server as HTTPSServer } from "https" ;
3
+ import type { Http2SecureServer } from "http2" ;
3
4
import { createReadStream } from "fs" ;
4
5
import { createDeflate , createGzip , createBrotliCompress } from "zlib" ;
5
6
import accepts = require( "accepts" ) ;
@@ -155,7 +156,7 @@ export class Server<
155
156
* @private
156
157
*/
157
158
_connectTimeout : number ;
158
- private httpServer : http . Server | HTTPSServer ;
159
+ private httpServer : http . Server | HTTPSServer | Http2SecureServer ;
159
160
160
161
/**
161
162
* Server constructor.
@@ -165,7 +166,7 @@ export class Server<
165
166
*/
166
167
constructor ( opts ?: Partial < ServerOptions > ) ;
167
168
constructor (
168
- srv ?: http . Server | HTTPSServer | number ,
169
+ srv ?: http . Server | HTTPSServer | Http2SecureServer | number ,
169
170
opts ?: Partial < ServerOptions >
170
171
) ;
171
172
constructor (
@@ -174,6 +175,7 @@ export class Server<
174
175
| Partial < ServerOptions >
175
176
| http . Server
176
177
| HTTPSServer
178
+ | Http2SecureServer
177
179
| number ,
178
180
opts ?: Partial < ServerOptions >
179
181
) ;
@@ -183,6 +185,7 @@ export class Server<
183
185
| Partial < ServerOptions >
184
186
| http . Server
185
187
| HTTPSServer
188
+ | Http2SecureServer
186
189
| number ,
187
190
opts : Partial < ServerOptions > = { }
188
191
) {
@@ -204,7 +207,9 @@ export class Server<
204
207
this . sockets = this . of ( "/" ) ;
205
208
this . opts = opts ;
206
209
if ( srv || typeof srv == "number" )
207
- this . attach ( srv as http . Server | HTTPSServer | number ) ;
210
+ this . attach (
211
+ srv as http . Server | HTTPSServer | Http2SecureServer | number
212
+ ) ;
208
213
}
209
214
210
215
/**
@@ -332,7 +337,7 @@ export class Server<
332
337
* @return self
333
338
*/
334
339
public listen (
335
- srv : http . Server | HTTPSServer | number ,
340
+ srv : http . Server | HTTPSServer | Http2SecureServer | number ,
336
341
opts : Partial < ServerOptions > = { }
337
342
) : this {
338
343
return this . attach ( srv , opts ) ;
@@ -346,7 +351,7 @@ export class Server<
346
351
* @return self
347
352
*/
348
353
public attach (
349
- srv : http . Server | HTTPSServer | number ,
354
+ srv : http . Server | HTTPSServer | Http2SecureServer | number ,
350
355
opts : Partial < ServerOptions > = { }
351
356
) : this {
352
357
if ( "function" == typeof srv ) {
@@ -452,7 +457,7 @@ export class Server<
452
457
* @private
453
458
*/
454
459
private initEngine (
455
- srv : http . Server | HTTPSServer ,
460
+ srv : http . Server | HTTPSServer | Http2SecureServer ,
456
461
opts : EngineOptions & AttachOptions
457
462
) : void {
458
463
// initialize engine
@@ -475,7 +480,9 @@ export class Server<
475
480
* @param srv http server
476
481
* @private
477
482
*/
478
- private attachServe ( srv : http . Server | HTTPSServer ) : void {
483
+ private attachServe (
484
+ srv : http . Server | HTTPSServer | Http2SecureServer
485
+ ) : void {
479
486
debug ( "attaching client serving req handler" ) ;
480
487
481
488
const evs = srv . listeners ( "request" ) . slice ( 0 ) ;
0 commit comments