本文整理匯總了PHP中Symfony\Component\HttpFoundation\Response::setDate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Response::setDate方法的具體用法?PHP Response::setDate怎麽用?PHP Response::setDate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\HttpFoundation\Response
的用法示例。
在下文中一共展示了Response::setDate方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: sendHeaders
/**
* Sends HTTP headers.
*
* @param ReactResponse $response
* @param SymfonyResponse $sf_response
*/
private function sendHeaders(ReactResponse $response, SymfonyResponse $sf_response)
{
// date
if (!$sf_response->headers->has('Date')) {
$sf_response->setDate(\DateTime::createFromFormat('U', time()));
}
$headers = $sf_response->headers->allPreserveCase();
// cookies
foreach ($sf_response->headers->getCookies() as $cookie) {
if (!isset($headers['Set-Cookie'])) {
$headers['Set-Cookie'] = [];
}
$headers['Set-Cookie'][] = (string) $cookie;
}
$response->writeHead($sf_response->getStatusCode(), $headers);
}
示例2: assertResponseEquals
protected function assertResponseEquals(Response $expected, Response $actual)
{
$expected->setDate($actual->getDate());
$this->assertEquals($expected, $actual);
}
示例3: store
/**
* Writes the Response to the cache.
*
* @param Request $request A Request instance
* @param Response $response A Response instance
*
* @throws \Exception
*/
protected function store(Request $request, Response $response)
{
if (!$response->headers->has('Date')) {
$response->setDate(\DateTime::createFromFormat('U', time()));
}
try {
$this->store->write($request, $response);
$this->record($request, 'store');
$response->headers->set('Age', $response->getAge());
} catch (\Exception $e) {
$this->record($request, 'store-failed');
if ($this->options['debug']) {
throw $e;
}
}
// now that the response is cached, release the lock
$this->store->unlock($request);
}
示例4: createResponse
public function createResponse($lMT)
{
$response = new Response();
$response->setPublic();
$response->setDate(new \DateTime("now"));
$response->setMaxAge($this->config->getMaxAge());
$response->setSharedMaxAge($this->config->getMaxAgeShared());
$response->setLastModified(new \DateTime($lMT));
return $response;
}