File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -419,6 +419,7 @@ class Parser extends HTTPParser {
419419 const request = client [ kQueue ] [ client [ kRunningIdx ] ]
420420
421421 // TODO: Check for content-length mismatch?
422+ // TODO: keep-alive timeout & max?
422423
423424 assert ( this . statusCode < 200 )
424425
@@ -815,6 +816,8 @@ function write (client, request) {
815816 socket . write ( `content-length: ${ contentLength } \r\n` , 'ascii' )
816817 }
817818
819+ // TODO: keep-alive timeout=client[kSocketTimeout]?
820+
818821 if ( method === 'HEAD' ) {
819822 // https://github.com/mcollina/undici/issues/258
820823
Original file line number Diff line number Diff line change @@ -122,6 +122,11 @@ class Request extends AsyncResource {
122122 key . toLowerCase ( ) === 'connection'
123123 ) {
124124 throw new InvalidArgumentError ( 'invalid connection header' )
125+ } else if (
126+ key . length === 10 &&
127+ key . toLowerCase ( ) === 'keep-alive'
128+ ) {
129+ throw new InvalidArgumentError ( 'invalid keep-alive header' )
125130 } else {
126131 header += `${ key } : ${ val } \r\n`
127132 }
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ const { test } = require('tap')
44const { Client, errors } = require ( '..' )
55
66test ( 'invalid headers' , ( t ) => {
7- t . plan ( 5 )
7+ t . plan ( 6 )
88
99 const client = new Client ( 'http://localhost:3000' )
1010 t . teardown ( client . destroy . bind ( client ) )
@@ -38,6 +38,16 @@ test('invalid headers', (t) => {
3838 t . ok ( err instanceof errors . InvalidArgumentError )
3939 } )
4040
41+ client . request ( {
42+ path : '/' ,
43+ method : 'GET' ,
44+ headers : {
45+ 'keep-alive' : 'timeout=5'
46+ }
47+ } , ( err , data ) => {
48+ t . ok ( err instanceof errors . InvalidArgumentError )
49+ } )
50+
4151 client . request ( {
4252 path : '/' ,
4353 method : 'GET' ,
You can’t perform that action at this time.
0 commit comments