File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -142,7 +142,14 @@ public function getProtocolVersion(): string
142142 */
143143 public function isJSON ()
144144 {
145- return $ this ->hasHeader ('Content-Type ' )
146- && $ this ->header ('Content-Type ' )->getValue () === 'application/json ' ;
145+ if (! $ this ->hasHeader ('Content-Type ' ))
146+ {
147+ return false ;
148+ }
149+
150+ $ header = $ this ->header ('Content-Type ' )->getValue ();
151+ $ parts = explode ('; ' , $ header );
152+
153+ return in_array ('application/json ' , $ parts , true );
147154 }
148155}
Original file line number Diff line number Diff line change @@ -349,4 +349,10 @@ public function testIsJsonReturnsTrue()
349349 $ this ->assertTrue ($ this ->message ->isJSON ());
350350 }
351351
352+ public function testIsJsonWorksWithExtendedContentType ()
353+ {
354+ $ this ->message ->setHeader ('Content-Type ' , 'application/json;charset=UTF-8 ' );
355+ $ this ->assertTrue ($ this ->message ->isJSON ());
356+ }
357+
352358}
You can’t perform that action at this time.
0 commit comments