diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-10-01 09:09:19 +0000 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-10-01 09:09:19 +0000 |
| commit | de136ea2be9eb2c7f10b65bc02c7ef8e1d2214cf (patch) | |
| tree | 924809366d3e1d16147ba537362590c908f05b2e /lib/classes/JsonApi | |
| parent | e39801cc034847bb1389c3cdf43ad072b2f0306f (diff) | |
rework JsonApiController::doesRequestHaveBody() by checking for Content-Length...
Closes #4652
Merge request studip/studip!3462
Diffstat (limited to 'lib/classes/JsonApi')
| -rw-r--r-- | lib/classes/JsonApi/JsonApiController.php | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/classes/JsonApi/JsonApiController.php b/lib/classes/JsonApi/JsonApiController.php index a60c0e2..cece86a 100644 --- a/lib/classes/JsonApi/JsonApiController.php +++ b/lib/classes/JsonApi/JsonApiController.php @@ -402,7 +402,7 @@ class JsonApiController $request = $this->container->get('request'); if ($this->doesRequestHaveBody($request)) { $contentType = $request->getHeader(HeaderParametersParserInterface::HEADER_CONTENT_TYPE); - if (count($contentType)) { + if (count($contentType) > 0) { $mediaType = $this->factory->createMediaType( MediaTypeInterface::JSON_API_TYPE, MediaTypeInterface::JSON_API_SUB_TYPE @@ -418,11 +418,6 @@ class JsonApiController private function doesRequestHaveBody(Request $request): bool { - if (count($request->getHeader('Transfer-Encoding'))) { - return true; - } - $contentLength = $request->getHeader('Content-Length'); - - return count($contentLength) && $contentLength[0] > 0; + return in_array($request->getMethod(), ['POST', 'PATCH']); } } |
