@@ -9,7 +9,11 @@ const server1 = http2.createServer();
99server1 . listen ( 0 , common . mustCall ( ( ) => {
1010 const session = http2 . connect ( `http://localhost:${ server1 . address ( ) . port } ` ) ;
1111 // Check for req headers
12- session . request ( { 'no underscore' : 123 } ) ;
12+ assert . throws ( ( ) => {
13+ session . request ( { 'no underscore' : 123 } ) ;
14+ } , {
15+ code : 'ERR_INVALID_HTTP_TOKEN'
16+ } ) ;
1317 session . on ( 'error' , common . mustCall ( ( e ) => {
1418 assert . strictEqual ( e . code , 'ERR_INVALID_HTTP_TOKEN' ) ;
1519 server1 . close ( ) ;
@@ -18,15 +22,18 @@ server1.listen(0, common.mustCall(() => {
1822
1923const server2 = http2 . createServer ( common . mustCall ( ( req , res ) => {
2024 // check for setHeader
21- res . setHeader ( 'x y z' , 123 ) ;
25+ assert . throws ( ( ) => {
26+ res . setHeader ( 'x y z' , 123 ) ;
27+ } , {
28+ code : 'ERR_INVALID_HTTP_TOKEN'
29+ } ) ;
2230 res . end ( ) ;
2331} ) ) ;
2432
2533server2 . listen ( 0 , common . mustCall ( ( ) => {
2634 const session = http2 . connect ( `http://localhost:${ server2 . address ( ) . port } ` ) ;
2735 const req = session . request ( ) ;
28- req . on ( 'error' , common . mustCall ( ( e ) => {
29- assert . strictEqual ( e . code , 'ERR_HTTP2_STREAM_ERROR' ) ;
36+ req . on ( 'end' , common . mustCall ( ( ) => {
3037 session . close ( ) ;
3138 server2 . close ( ) ;
3239 } ) ) ;
@@ -39,16 +46,15 @@ const server3 = http2.createServer(common.mustCall((req, res) => {
3946 'an invalid header' : 123
4047 } ) ;
4148 } ) , {
42- code : 'ERR_HTTP2_INVALID_STREAM '
49+ code : 'ERR_INVALID_HTTP_TOKEN '
4350 } ) ;
4451 res . end ( ) ;
4552} ) ) ;
4653
4754server3 . listen ( 0 , common . mustCall ( ( ) => {
4855 const session = http2 . connect ( `http://localhost:${ server3 . address ( ) . port } ` ) ;
4956 const req = session . request ( ) ;
50- req . on ( 'error' , common . mustCall ( ( e ) => {
51- assert . strictEqual ( e . code , 'ERR_HTTP2_STREAM_ERROR' ) ;
57+ req . on ( 'end' , common . mustCall ( ( ) => {
5258 server3 . close ( ) ;
5359 session . close ( ) ;
5460 } ) ) ;
0 commit comments