Skip to content

Commit 1545ad9

Browse files
committed
Validate supported Content-Type header values in base request
1 parent 20a7dcf commit 1545ad9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Http/Requests/JsonApiRequest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,15 @@ protected function getValidatorInstance()
5050

5151
/**
5252
* Perform additional logic before the request input is validated.
53+
*
54+
* @throws HttpException
5355
*/
5456
protected function beforeValidation()
5557
{
58+
if (!$this->isJson()) {
59+
throw new HttpException('Unsupported Content-Type value', Reponse::HTTP_UNSUPPORTED_MEDIA_TYPE);
60+
}
61+
5662
if ($this->exists('include') && config('jsonapi.enable_included_resources') === false) {
5763
throw new HttpException('Inclusion of related resources is not supported');
5864
}

0 commit comments

Comments
 (0)