removed cache breaking behavior

pull/630/head
n0nag0n 3 days ago
parent f4115927fb
commit 2c9b02ec28

@ -842,8 +842,8 @@ class Engine
?string $charset = 'utf-8', ?string $charset = 'utf-8',
int $option = 0 int $option = 0
): void { ): void {
// add some default flags // add some default flags
$option |= JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR; $option |= JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR;
$json = $encode ? json_encode($data, $option) : $data; $json = $encode ? json_encode($data, $option) : $data;
$this->response() $this->response()

@ -211,8 +211,8 @@ class Request
$this->data->setData($data); $this->data->setData($data);
} }
} }
// Check PUT, PATCH, DELETE for application/x-www-form-urlencoded data // Check PUT, PATCH, DELETE for application/x-www-form-urlencoded data
} else if (in_array($this->method, [ 'PUT', 'DELETE', 'PATCH' ], true) === true) { } elseif (in_array($this->method, [ 'PUT', 'DELETE', 'PATCH' ], true) === true) {
$body = $this->getBody(); $body = $this->getBody();
if ($body !== '') { if ($body !== '') {
$data = []; $data = [];

@ -432,11 +432,6 @@ class Response
} }
if ($this->headersSent() === false) { if ($this->headersSent() === false) {
// If you haven't set a Cache-Control header, we'll assume you don't want caching
if ($this->getHeader('Cache-Control') === null) {
$this->cache(false);
}
$this->sendHeaders(); $this->sendHeaders();
} }

@ -163,7 +163,7 @@ class RequestTest extends TestCase
'base' => '/vagrant/public', 'base' => '/vagrant/public',
'query' => new Collection(), 'query' => new Collection(),
'type' => '', 'type' => '',
'method' => 'GET' 'method' => 'GET'
]); ]);
$this->assertEquals('/flightphp', $request->url); $this->assertEquals('/flightphp', $request->url);
} }
@ -174,7 +174,7 @@ class RequestTest extends TestCase
'url' => '', 'url' => '',
'base' => '/vagrant/public', 'base' => '/vagrant/public',
'type' => '', 'type' => '',
'method' => 'GET' 'method' => 'GET'
]); ]);
$this->assertEquals('/', $request->url); $this->assertEquals('/', $request->url);
} }
@ -193,13 +193,13 @@ class RequestTest extends TestCase
'data' => new Collection(), 'data' => new Collection(),
'query' => new Collection(), 'query' => new Collection(),
'stream_path' => $stream_path, 'stream_path' => $stream_path,
'method' => 'POST' 'method' => 'POST'
]); ]);
$this->assertEquals([ 'foo' => 'bar' ], $request->data->getData()); $this->assertEquals([ 'foo' => 'bar' ], $request->data->getData());
$this->assertEquals('{"foo":"bar"}', $request->getBody()); $this->assertEquals('{"foo":"bar"}', $request->getBody());
} }
public function testInitWithFormBody() public function testInitWithFormBody()
{ {
// create dummy file to pull request body from // create dummy file to pull request body from
$tmpfile = tmpfile(); $tmpfile = tmpfile();
@ -213,12 +213,12 @@ class RequestTest extends TestCase
'data' => new Collection(), 'data' => new Collection(),
'query' => new Collection(), 'query' => new Collection(),
'stream_path' => $stream_path, 'stream_path' => $stream_path,
'method' => 'PATCH' 'method' => 'PATCH'
]); ]);
$this->assertEquals([ $this->assertEquals([
'foo' => 'bar', 'foo' => 'bar',
'baz' => 'qux' 'baz' => 'qux'
], $request->data->getData()); ], $request->data->getData());
$this->assertEquals('foo=bar&baz=qux', $request->getBody()); $this->assertEquals('foo=bar&baz=qux', $request->getBody());
} }

@ -268,9 +268,6 @@ class ResponseTest extends TestCase
'HTTP/1.1 200 OK', 'HTTP/1.1 200 OK',
'Content-Type: text/html', 'Content-Type: text/html',
'X-Test: test', 'X-Test: test',
'Expires: Mon, 26 Jul 1997 05:00:00 GMT',
'Cache-Control: no-store, no-cache, must-revalidate, max-age=0',
'Pragma: no-cache',
'Content-Length: 9' 'Content-Length: 9'
], $sent_headers); ], $sent_headers);
} }

@ -81,10 +81,10 @@ PHP;
protected function removeColors(string $str): string protected function removeColors(string $str): string
{ {
// replace \n with \r\n if windows // replace \n with \r\n if windows
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$str = str_replace("\r\n", "\n", $str); $str = str_replace("\r\n", "\n", $str);
} }
return preg_replace('/\e\[[\d;]*m/', '', $str); return preg_replace('/\e\[[\d;]*m/', '', $str);
} }

Loading…
Cancel
Save