Skip to content

Commit

Permalink
Revert raw body to normal property
Browse files Browse the repository at this point in the history
  • Loading branch information
freost committed Dec 19, 2024
1 parent 6b5b5b0 commit 58b4481
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
16 changes: 6 additions & 10 deletions src/mako/http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,15 @@ class Request
/**
* Raw request body.
*/
public protected(set) ?string $rawBody = null {
get {
if ($this->rawBody === null) {
$this->rawBody = file_get_contents('php://input');
}

return $this->rawBody;
}
}
protected ?string $rawBody = null;

/**
* Parsed request body.
*/
public protected(set) ?Body $body = null {
get {
if ($this->body === null) {
$this->body = new Body($this->rawBody, $this->getContentType());
$this->body = new Body($this->getRawBody(), $this->getContentType());
}

return $this->body;
Expand Down Expand Up @@ -354,6 +346,10 @@ public function getAttribute(string $name, mixed $default = null): mixed
*/
public function getRawBody(): string
{
if ($this->rawBody === null) {
$this->rawBody = file_get_contents('php://input');
}

return $this->rawBody;
}

Expand Down
2 changes: 0 additions & 2 deletions tests/unit/http/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,6 @@ public function testBody(): void
{
$request = new Request(['body' => '{"foo":"bar","baz":["bax"]}']);

$this->assertEquals('{"foo":"bar","baz":["bax"]}', $request->rawBody);

$this->assertEquals('{"foo":"bar","baz":["bax"]}', $request->getRawBody());
}

Expand Down

0 comments on commit 58b4481

Please sign in to comment.