Skip to content

Commit

Permalink
[HTTP] Remove Message::isJson()
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Feb 7, 2021
1 parent 6660ce9 commit 55b4308
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 22 deletions.
2 changes: 1 addition & 1 deletion system/HTTP/IncomingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public function isSecure(): bool
*/
public function getVar($index = null, $filter = null, $flags = null)
{
if ($this->isJSON())
if (strpos('application/json', $this->getHeaderLine('Content-Type')) !== false)

This comment has been minimized.

Copy link
@lenuse

lenuse Mar 2, 2021

Contributor

It should be added to determine whether $this->body is null

{
if (is_null($index))
{
Expand Down
20 changes: 0 additions & 20 deletions system/HTTP/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,24 +132,4 @@ public function getProtocolVersion(): string
{
return $this->protocolVersion ?? '1.1';
}

/**
* Determines if this is a json message based on the Content-Type header
*
* @return boolean
*
* @deprecated Use header calls directly
*/
public function isJSON()
{
if (! $this->hasHeader('Content-Type'))
{
return false;
}

$header = $this->header('Content-Type')->getValue();
$parts = explode(';', $header);

return in_array('application/json', $parts, true);
}
}
2 changes: 1 addition & 1 deletion system/Validation/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ protected function processRules(string $field, string $label = null, $value, $ru
*/
public function withRequest(RequestInterface $request): ValidationInterface
{
if ($request->isJSON())
if (strpos('application/json', $request->getHeaderLine('Content-Type')) !== false)
{
$this->data = $request->getJSON(true);
return $this;
Expand Down

0 comments on commit 55b4308

Please sign in to comment.