@@ -96,23 +96,23 @@ describe('open-api HTTP adapter', function () {
9696 expect ( agentOptions [ 0 ] . requestTls . allowH2 ) . to . equal ( false ) ;
9797 } ) ;
9898
99- it ( 'adds a curl-like Accept header by default in Node.js ' , async function ( ) {
99+ it ( 'normalizes Node.js request header names to lowercase ' , async function ( ) {
100100 await HTTP ( {
101101 headers : {
102102 'User-Agent' : 'Surge' ,
103103 } ,
104104 } ) . get ( 'https://example.com/subscription' ) ;
105105
106106 expect ( requestOptions . headers ) . to . include ( {
107- 'User-Agent ' : 'Surge' ,
108- Accept : '*/*' ,
107+ 'user-agent ' : 'Surge' ,
108+ accept : '*/*' ,
109109 } ) ;
110110 } ) ;
111111
112112 it ( 'keeps an explicit Accept header in Node.js' , async function ( ) {
113113 await HTTP ( {
114114 headers : {
115- accept : 'application/json' ,
115+ Accept : 'application/json' ,
116116 } ,
117117 } ) . get ( 'https://example.com/subscription' ) ;
118118
@@ -121,6 +121,20 @@ describe('open-api HTTP adapter', function () {
121121 } ) ;
122122 } ) ;
123123
124+ it ( 'preserves __proto__ headers when normalizing names' , async function ( ) {
125+ await HTTP ( {
126+ headers : Object . fromEntries ( [ [ '__proto__' , 'sent' ] ] ) ,
127+ } ) . get ( 'https://example.com/subscription' ) ;
128+
129+ expect (
130+ Object . prototype . hasOwnProperty . call (
131+ requestOptions . headers ,
132+ '__proto__' ,
133+ ) ,
134+ ) . to . equal ( true ) ;
135+ expect ( requestOptions . headers . __proto__ ) . to . equal ( 'sent' ) ;
136+ } ) ;
137+
124138 it ( 'omits Accept when callers set it to null in Node.js' , async function ( ) {
125139 await HTTP ( {
126140 headers : {
@@ -130,7 +144,7 @@ describe('open-api HTTP adapter', function () {
130144 } ) . get ( 'https://example.com/subscription' ) ;
131145
132146 expect ( requestOptions . headers ) . to . deep . equal ( {
133- 'User-Agent ' : 'Surge' ,
147+ 'user-agent ' : 'Surge' ,
134148 } ) ;
135149 } ) ;
136150} ) ;
0 commit comments