6
6
import {
7
7
expect ,
8
8
givenHttpServerConfig ,
9
+ Http2sOptions ,
9
10
httpGetAsync ,
10
11
httpsGetAsync ,
11
12
skipOnTravis ,
@@ -18,7 +19,7 @@ import os from 'os';
18
19
import pEvent from 'p-event' ;
19
20
import path from 'path' ;
20
21
import { HttpOptions , HttpServer , HttpsOptions } from '../../' ;
21
- import { HttpServerOptions } from '../../http-server' ;
22
+ import { Http2Options , HttpServerOptions } from '../../http-server' ;
22
23
23
24
describe ( 'HttpServer (integration)' , ( ) => {
24
25
let server : HttpServer | undefined ;
@@ -294,6 +295,13 @@ describe('HttpServer (integration)', () => {
294
295
} ) . to . throw ( / N a m e d p i p e t e s t \. p i p e d o e s N O T s t a r t w i t h / ) ;
295
296
} ) ;
296
297
298
+ it ( 'supports HTTP/2 HTTP' , async ( ) => {
299
+ const http2Server = givenHttp2Server ( ) ;
300
+ await http2Server . start ( ) ;
301
+ const response = await httpGetAsync ( http2Server . url ) ;
302
+ expect ( response . statusCode ) . to . equal ( 200 ) ;
303
+ } ) ;
304
+
297
305
function getAddressFamily ( httpServer : HttpServer ) {
298
306
if ( ! httpServer || ! httpServer . address ) return undefined ;
299
307
if ( typeof httpServer . address === 'string' ) {
@@ -353,4 +361,25 @@ describe('HttpServer (integration)', () => {
353
361
}
354
362
return new HttpServer ( dummyRequestHandler , options ) ;
355
363
}
364
+
365
+ function givenHttp2Server ( ) : HttpServer {
366
+ const options = givenHttpServerConfig < Http2Options > ( {
367
+ protocol : 'http2' ,
368
+ } ) ;
369
+
370
+ return new HttpServer ( dummyRequestHandler , options ) ;
371
+ }
372
+
373
+ function givenHttp2sServer ( {
374
+ allowHttp1 = false ,
375
+ } : {
376
+ allowHttp1 : boolean ;
377
+ } ) : HttpServer {
378
+ const options = givenHttpServerConfig < Http2sOptions > ( {
379
+ protocol : 'http2s' ,
380
+ allowHTTP1 : allowHttp1 ,
381
+ } ) ;
382
+
383
+ return new HttpServer ( dummyRequestHandler , options ) ;
384
+ }
356
385
} ) ;
0 commit comments