File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -117,6 +117,11 @@ class Request extends AsyncResource {
117117 key . toLowerCase ( ) === 'transfer-encoding'
118118 ) {
119119 throw new InvalidArgumentError ( 'invalid transfer-encoding header' )
120+ } else if (
121+ key . length === 10 &&
122+ key . toLowerCase ( ) === 'connection'
123+ ) {
124+ throw new InvalidArgumentError ( 'invalid connection header' )
120125 } else {
121126 header += `${ key } : ${ val } \r\n`
122127 }
Original file line number Diff line number Diff line change 11'use strict'
22
33const { test } = require ( 'tap' )
4- const { Client, errors } = require ( '..' )
4+ const { Client } = require ( '..' )
55const { createServer } = require ( 'http' )
66const net = require ( 'net' )
77
@@ -36,36 +36,6 @@ test('ignore informational response', (t) => {
3636 } )
3737} )
3838
39- test ( 'error 101' , ( t ) => {
40- t . plan ( 2 )
41-
42- const server = net . createServer ( ( socket ) => {
43- socket . write ( 'HTTP/1.1 101 Switching Protocols\r\n' )
44- socket . write ( 'Upgrade: TLS/1.0, HTTP/1.1\r\n' )
45- socket . write ( 'Connection: Upgrade\r\n' )
46- socket . write ( '\r\n' )
47- } )
48- t . teardown ( server . close . bind ( server ) )
49- server . listen ( 0 , ( ) => {
50- const client = new Client ( `http://localhost:${ server . address ( ) . port } ` )
51- t . teardown ( client . destroy . bind ( client ) )
52-
53- client . request ( {
54- path : '/' ,
55- method : 'GET' ,
56- headers : {
57- Connection : 'upgrade' ,
58- Upgrade : 'example/1, foo/2'
59- }
60- } , ( err ) => {
61- t . ok ( err instanceof errors . NotSupportedError )
62- } )
63- client . on ( 'disconnect' , ( ) => {
64- t . pass ( )
65- } )
66- } )
67- } )
68-
6939test ( 'error 103 body' , ( t ) => {
7040 t . plan ( 2 )
7141
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 ( 4 )
7+ t . plan ( 5 )
88
99 const client = new Client ( 'http://localhost:3000' )
1010 t . teardown ( client . destroy . bind ( client ) )
@@ -28,6 +28,16 @@ test('invalid headers', (t) => {
2828 t . ok ( err instanceof errors . InvalidArgumentError )
2929 } )
3030
31+ client . request ( {
32+ path : '/' ,
33+ method : 'GET' ,
34+ headers : {
35+ connection : 'close'
36+ }
37+ } , ( err , data ) => {
38+ t . ok ( err instanceof errors . InvalidArgumentError )
39+ } )
40+
3141 client . request ( {
3242 path : '/' ,
3343 method : 'GET' ,
You can’t perform that action at this time.
0 commit comments