Skip to content

Commit

Permalink
Added application/json support
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladas Lapinskas committed Feb 24, 2020
1 parent 3048c0e commit d5b073f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Ubiquity new firstProject -a
```
"require": {
...
"lapinskas\/roadrunner-ubiquity" : "0.0.6.x-dev"
"lapinskas\/roadrunner-ubiquity" : "0.0.7.x-dev"
},
```

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "lapinskas/roadrunner-ubiquity",
"type": "library",
"version": "0.0.6",
"version": "0.0.7",
"description": "RoadRunner and Ubiquity integration",
"keywords": ["roadrunner","ubiquity"],
"homepage": "https://github.com/Lapinskas/roadrunner-ubiquity",
Expand Down
19 changes: 10 additions & 9 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ public function __construct()
/**
* @return boolean
*/
public function acceptRequest() : bool
public function acceptRequest(): bool
{
if (null === $this->rawRequest = $this->httpClient->acceptRequest()) {
return false;
}

// Prepare all superglobals
$_SERVER = $this->prepareServer();
$_GET = $this->prepareGet();
$_POST = $this->preparePost();
$_COOKIE = $this->prepareCookie();
$_FILES = $this->prepareFiles();
$_REQUEST = $this->prepareRequest();
$_SERVER = $this->prepareServer();
$_GET = $this->prepareGet();
$_POST = $this->preparePost();
$_COOKIE = $this->prepareCookie();
$_FILES = $this->prepareFiles();
$_REQUEST = $this->prepareRequest();

// Start output buffering
ob_start();
Expand Down Expand Up @@ -184,13 +184,14 @@ protected function preparePost(): array

if (
isset($_SERVER['CONTENT_TYPE']) && (
false !== strpos($_SERVER['CONTENT_TYPE'], 'application/json') ||
false !== strpos($_SERVER['CONTENT_TYPE'], 'application/x-www-form-urlencoded') ||
false !== strpos($_SERVER['CONTENT_TYPE'], 'multipart/form-data')
)
) {
$post = array_merge(
$post,
(array) json_decode($this->rawRequest['body'])
json_decode($this->rawRequest['body'], true)
);
}

Expand All @@ -212,7 +213,7 @@ protected function prepareCookie(): array
*
* @return array
*/
protected function prepareFiles() : array
protected function prepareFiles(): array
{
$ctx = $this->rawRequest['ctx'];

Expand Down

0 comments on commit d5b073f

Please sign in to comment.