File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Flags: --expose-http2
2
+ 'use strict' ;
3
+
4
+ const common = require ( '../common' ) ;
5
+ if ( ! common . hasCrypto )
6
+ common . skip ( 'missing crypto' ) ;
7
+ const assert = require ( 'assert' ) ;
8
+ const http2 = require ( 'http2' ) ;
9
+
10
+ const expectValue = 'meoww' ;
11
+
12
+ const server = http2 . createServer ( common . mustNotCall ( ) ) ;
13
+
14
+ server . once ( 'checkExpectation' , common . mustCall ( ( req , res ) => {
15
+ assert . strictEqual ( req . headers [ 'expect' ] , expectValue ) ;
16
+ res . statusCode = 417 ;
17
+ res . end ( ) ;
18
+ } ) ) ;
19
+
20
+ server . listen ( 0 , common . mustCall ( ( ) => nextTest ( 2 ) ) ) ;
21
+
22
+ function nextTest ( testsToRun ) {
23
+ if ( ! testsToRun ) {
24
+ return server . close ( ) ;
25
+ }
26
+
27
+ const port = server . address ( ) . port ;
28
+ const client = http2 . connect ( `http://localhost:${ port } ` ) ;
29
+ const req = client . request ( {
30
+ ':path' : '/' ,
31
+ ':method' : 'GET' ,
32
+ ':scheme' : 'http' ,
33
+ ':authority' : `localhost:${ port } ` ,
34
+ expect : expectValue
35
+ } ) ;
36
+
37
+ req . on ( 'response' , common . mustCall ( ( headers ) => {
38
+ assert . strictEqual ( headers [ ':status' ] , 417 ) ;
39
+ req . resume ( ) ;
40
+ } ) ) ;
41
+
42
+ req . on ( 'end' , common . mustCall ( ( ) => {
43
+ client . destroy ( ) ;
44
+ nextTest ( testsToRun - 1 ) ;
45
+ } ) ) ;
46
+ }
You can’t perform that action at this time.
0 commit comments