File tree 2 files changed +13
-2
lines changed
src/OpenSearch/Serializers
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -93,8 +93,9 @@ private function isJson(array $headers): bool
93
93
}
94
94
95
95
// Check PSR-7 headers.
96
- if (array_key_exists ('Content-Type ' , $ headers )) {
97
- foreach ($ headers ['Content-Type ' ] as $ type ) {
96
+ $ lowercaseHeaders = array_change_key_case ($ headers , CASE_LOWER );
97
+ if (array_key_exists ('content-type ' , $ lowercaseHeaders )) {
98
+ foreach ($ lowercaseHeaders ['content-type ' ] as $ type ) {
98
99
if (str_contains ($ type , 'json ' )) {
99
100
return true ;
100
101
}
Original file line number Diff line number Diff line change @@ -68,6 +68,16 @@ public function testDeserialize(): void
68
68
$ this ->assertEquals ('bar ' , $ result ['foo ' ]);
69
69
}
70
70
71
+ public function testDeserializeLowercaseContentTypeHeader (): void
72
+ {
73
+ $ data = '{ "foo" : "bar" } ' ;
74
+ $ headers = ['content-type ' => ['application/json ' ]];
75
+
76
+ $ result = $ this ->serializer ->deserialize ($ data , $ headers );
77
+
78
+ $ this ->assertEquals ('bar ' , $ result ['foo ' ]);
79
+ }
80
+
71
81
public function testDeserializeWithLegacyContentTypeHeader (): void
72
82
{
73
83
$ data = '{ "foo" : "bar" } ' ;
You can’t perform that action at this time.
0 commit comments