Skip to content

Commit

Permalink
Fixes the processingf request data from php input
Browse files Browse the repository at this point in the history
  • Loading branch information
papac committed Nov 9, 2023
1 parent 1e8bfd0 commit 6a60e65
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Application/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ public function __construct(Request $request, Response $response)

$this->capsule = Capsule::getInstance();

$this->capsule->instance('request', $request);
$this->capsule->instance('response', $response);
$this->capsule->instance('request', $request);
$this->capsule->instance('app', $this);

$this->request->capture();
parent::__construct($request->method(), $request->get('_method'));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Client/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ private function addFields(array $data): void
if (count($data) == 0) {
return;
}

if ($this->accept_json) {
$payload = json_encode($data);
} else {
Expand Down
21 changes: 20 additions & 1 deletion src/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,24 @@ class Request
*/
private string $id;

/**
* Define the request captured
*
* @var bool
*/
private bool $capture = false;

/**
* Request constructor
*
* @return mixed
*/
private function __construct()
public function capture()
{
if ($this->capture) {
return;
}

$data = [];
$this->id = "req_" . sha1(uniqid() . time());

Expand Down Expand Up @@ -76,6 +87,8 @@ private function __construct()

$this->input[$key] = $value;
}

$this->capture = true;
}

/**
Expand Down Expand Up @@ -348,6 +361,12 @@ public function isAjax(): bool
return true;
}

$content_type = $this->getHeader("content-type");

if ($content_type && str_contains($content_type, "application/json")) {
return true;
}

return false;
}

Expand Down
1 change: 0 additions & 1 deletion tests/Queue/QueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public function test_instance_of_adapter($connection)
} elseif ($connection == "sync") {
$this->assertInstanceOf(SyncAdapter::class, $adapter);
}

}

/**
Expand Down

0 comments on commit 6a60e65

Please sign in to comment.