File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ public function toApiGatewayFormatV2(): array
72
72
} else {
73
73
// Make sure the values are never arrays
74
74
// because API Gateway v2 does not support multi-value headers
75
- $ headers [$ name ] = is_array ($ values ) ? end ( $ values ) : $ values ;
75
+ $ headers [$ name ] = is_array ($ values ) ? implode ( ' , ' , $ values ) : $ values ;
76
76
}
77
77
}
78
78
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ public function test headers are capitalized()
58
58
], $ response ->toApiGatewayFormatV2 ());
59
59
}
60
60
61
- public function test nested arrays in headers are flattened ()
61
+ public function test multi value headers ()
62
62
{
63
63
$ response = new HttpResponse ('' , [
64
64
'foo ' => ['bar ' , 'baz ' ],
@@ -76,8 +76,10 @@ public function test nested arrays in headers are flattened()
76
76
'cookies ' => [],
77
77
'isBase64Encoded ' => false ,
78
78
'statusCode ' => 200 ,
79
- // The last value is kept (when multiheaders are not enabled)
80
- 'headers ' => ['Foo ' => 'baz ' ],
79
+ // Headers are joined with a comma
80
+ // See https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.2
81
+ // API Gateway v2 does not support multi-value headers
82
+ 'headers ' => ['Foo ' => 'bar, baz ' ],
81
83
'body ' => '' ,
82
84
], $ response ->toApiGatewayFormatV2 ());
83
85
}
You can’t perform that action at this time.
0 commit comments