diff --git a/system/HTTP/Message.php b/system/HTTP/Message.php index 68fc59a8a4b3..793ed5642c17 100644 --- a/system/HTTP/Message.php +++ b/system/HTTP/Message.php @@ -142,7 +142,14 @@ public function getProtocolVersion(): string */ public function isJSON() { - return $this->hasHeader('Content-Type') - && $this->header('Content-Type')->getValue() === 'application/json'; + if (! $this->hasHeader('Content-Type')) + { + return false; + } + + $header = $this->header('Content-Type')->getValue(); + $parts = explode(';', $header); + + return in_array('application/json', $parts, true); } } diff --git a/tests/system/HTTP/MessageTest.php b/tests/system/HTTP/MessageTest.php index d2bc8aa7f89a..3972a63fdd33 100644 --- a/tests/system/HTTP/MessageTest.php +++ b/tests/system/HTTP/MessageTest.php @@ -349,4 +349,10 @@ public function testIsJsonReturnsTrue() $this->assertTrue($this->message->isJSON()); } + public function testIsJsonWorksWithExtendedContentType() + { + $this->message->setHeader('Content-Type', 'application/json;charset=UTF-8'); + $this->assertTrue($this->message->isJSON()); + } + }