Add support for application/scim+json content type

Signed-off-by: Stanimir Bozhilov <stanimir@audriga.com>
This commit is contained in:
Stanimir Bozhilov 2022-09-20 14:18:26 +02:00
parent 3950deb42f
commit f0dbe1148a

View file

@ -26,6 +26,7 @@ declare(strict_types=1);
* @author Thomas Tanghus <thomas@tanghus.net>
* @author Vincent Petry <vincent@nextcloud.com>
* @author Simon Leiner <simon@leiner.me>
* @author Stanimir Bozhilov <stanimir@audriga.com>
*
* @license AGPL-3.0
*
@ -404,6 +405,7 @@ class Request implements \ArrayAccess, \Countable, IRequest {
&& $this->getHeader('Content-Length') !== ''
&& strpos($this->getHeader('Content-Type'), 'application/x-www-form-urlencoded') === false
&& strpos($this->getHeader('Content-Type'), 'application/json') === false
&& strpos($this->getHeader('Content-Type'), 'application/scim+json') === false
) {
if ($this->content === false) {
throw new \LogicException(
@ -437,6 +439,15 @@ class Request implements \ArrayAccess, \Countable, IRequest {
$this->items['post'] = $params;
}
}
// 'application/scim+json' must be decoded manually.
} elseif (strpos($this->getHeader('Content-Type'), 'application/scim+json') !== false) {
$params = json_decode(file_get_contents($this->inputStream), true);
if ($params !== null && \count($params) > 0) {
$this->items['params'] = $params;
if ($this->method === 'POST') {
$this->items['post'] = $params;
}
}
// Handle application/x-www-form-urlencoded for methods other than GET
// or post correctly