本文整理汇总了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;
}