@@ -332,6 +332,48 @@ func TestIntegration(t *testing.T) {
332332 }
333333 })
334334
335+ t .Run ("javascript" , func (t * testing.T ) {
336+ require .Eventually (t , func () bool {
337+ req , err := http .NewRequest ("GET" , "http://localhost:1062/headers" , nil )
338+ require .NoError (t , err )
339+ req .Header .Set ("dog" , "cat" )
340+ req .Header .Set ("foo" , "bar" )
341+
342+ resp , err := http .DefaultClient .Do (req )
343+ if err != nil {
344+ t .Logf ("Envoy not ready yet: %v" , err )
345+ return false
346+ }
347+ defer func () {
348+ require .NoError (t , resp .Body .Close ())
349+ }()
350+ body , err := io .ReadAll (resp .Body )
351+ if err != nil {
352+ t .Logf ("Envoy not ready yet: %v" , err )
353+ return false
354+ }
355+
356+ t .Logf ("response: headers=%v, body=%s" , resp .Header , string (body ))
357+ require .Equal (t , 200 , resp .StatusCode )
358+
359+ // HttpBin returns a JSON object containing the request headers in this format.
360+ type httpBinHeadersBody struct {
361+ Headers map [string ][]string `json:"headers"`
362+ }
363+ var headersBody httpBinHeadersBody
364+ require .NoError (t , json .Unmarshal (body , & headersBody ))
365+
366+ require .Contains (t , headersBody .Headers ["X-Foo" ], "bar" )
367+ require .Contains (t , headersBody .Headers ["Foo" ], "bar" )
368+ require .Contains (t , headersBody .Headers ["Dog" ], "cat" )
369+
370+ // We also need to check that the response headers were mutated.
371+ require .Equal (t , "cat" , resp .Header .Get ("x-dog" ))
372+ require .Equal (t , "200" , resp .Header .Get ("x-status" ))
373+ return true
374+ }, 30 * time .Second , 200 * time .Millisecond )
375+ })
376+
335377 t .Run ("http_metrics" , func (t * testing.T ) {
336378 // Send test request
337379 require .Eventually (t , func () bool {
0 commit comments