Update
This commit is contained in:
@@ -58,7 +58,7 @@ class HttpRequest extends Request
|
||||
* @param array $files _FILES
|
||||
* @param array $cookies _COOKIE
|
||||
*/
|
||||
public function __construct(Server $server, array $queryString, array $postData, array $files, array $cookies)
|
||||
public function __construct(Server $server, array $queryString, array $postData, array $files, array $cookies, array $jsonData = [])
|
||||
{
|
||||
$request = array_merge($queryString, $postData);
|
||||
parent::__construct($server, $request);
|
||||
@@ -69,7 +69,7 @@ class HttpRequest extends Request
|
||||
$this->cookiesRaw = new Type\ParameterDictionary($cookies);
|
||||
$this->cookies = new Type\ParameterDictionary($this->prepareCookie($cookies));
|
||||
$this->headers = $this->buildHttpHeaders($server);
|
||||
$this->jsonData = new Type\ParameterDictionary();
|
||||
$this->jsonData = new Type\ParameterDictionary($jsonData);
|
||||
}
|
||||
|
||||
private function buildHttpHeaders(Server $server)
|
||||
@@ -594,4 +594,22 @@ class HttpRequest extends Request
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function decodeJsonStrict(): void
|
||||
{
|
||||
if (!$this->isJson())
|
||||
{
|
||||
throw new SystemException('Input is not valid JSON');
|
||||
}
|
||||
if (empty($this->jsonData->getValues()))
|
||||
{
|
||||
$json = Web\Json::decode(static::getInput());
|
||||
if (!is_array($json))
|
||||
{
|
||||
throw new SystemException('Decoded JSON is not an array');
|
||||
}
|
||||
|
||||
$this->jsonData = new Type\ParameterDictionary($json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user