mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
Added Content-Type: application/json body support for PSR-7 ServerRequest
This commit is contained in:
parent
a25d18bca7
commit
90c708db2b
|
|
@ -1,3 +1,9 @@
|
|||
# v1.6.0-rc.5
|
||||
## mm/dd/2019
|
||||
|
||||
1. [](#improved)
|
||||
* Added `Content-Type: application/json` body support for PSR-7 `ServerRequest`
|
||||
|
||||
# v1.6.0-rc.4
|
||||
## 03/20/2019
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,13 @@ class RequestProcessor extends ProcessorBase
|
|||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
|
||||
{
|
||||
$this->startTimer();
|
||||
|
||||
$header = $request->getHeaderLine('Content-Type');
|
||||
$type = trim(strstr($header, ';', true) ?: $header);
|
||||
if ($type === 'application/json') {
|
||||
$request = $request->withParsedBody(json_decode($request->getBody()->getContents(), true));
|
||||
}
|
||||
|
||||
$request = $request
|
||||
->withAttribute('grav', $this->container)
|
||||
->withAttribute('time', $_SERVER['REQUEST_TIME_FLOAT'] ?? GRAV_REQUEST_TIME)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user