本文整理汇总了PHP中Symfony\Component\HttpFoundation\Response::getProtocolVersion方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::getProtocolVersion方法的具体用法?PHP Response::getProtocolVersion怎么用?PHP Response::getProtocolVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\Response
的用法示例。
在下文中一共展示了Response::getProtocolVersion方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendResponseToMongrel
/**
* Sending back a response to mongrel2 webserver.
*
* @param Request $request
* @param Response $response
*/
private function sendResponseToMongrel(Request $request, Response $response)
{
$response->prepare($request);
// Map back our Symfony Response to a MongrelResponse.
$mongrelResponse = new MongrelResponse($request->attributes->get('mongrel2_uuid'), [$request->attributes->get('mongrel2_listener')]);
$mongrelResponse->setContent($response->getContent());
$headers = $response->headers->all();
foreach ($response->headers->getCookies() as $cookie) {
$headers['Set-Cookie'][] = $cookie;
}
$mongrelResponse->setHeaders($headers);
$mongrelResponse->setHttpVersion($response->getProtocolVersion());
$mongrelResponse->setStatusCode($response->getStatusCode());
$mongrelResponse->setReasonPhrase(Response::$statusTexts[$response->getStatusCode()]);
$this->handler->sendResponse($mongrelResponse);
}
示例2: logResponse
protected function logResponse(Response $response, Request $request)
{
if ($response->getStatusCode() >= 500) {
$color = LogLevel::ERROR;
} elseif ($response->getStatusCode() >= 400) {
$color = LogLevel::WARNING;
} elseif ($response->getStatusCode() >= 300) {
$color = LogLevel::NOTICE;
} elseif ($response->getStatusCode() >= 200) {
$color = LogLevel::INFO;
} else {
$color = LogLevel::INFO;
}
$msg = 'Response {response_status_code} for "{request_method} {request_uri}"';
$context = array('request_method' => $request->getMethod(), 'request_uri' => $request->getRequestUri(), 'response_status_code' => $response->getStatusCode(), 'response_charset' => $response->getCharset(), 'response_date' => $response->getDate(), 'response_etag' => $response->getEtag(), 'response_expires' => $response->getExpires(), 'response_last_modified' => $response->getLastModified(), 'response_max_age' => $response->getMaxAge(), 'response_protocol_version' => $response->getProtocolVersion(), 'response_ttl' => $response->getTtl(), 'response_vary' => $response->getVary());
$this->logger->log($color, $msg, $context);
}
示例3: testGetSetProtocolVersion
public function testGetSetProtocolVersion()
{
$response = new Response();
$this->assertEquals('1.0', $response->getProtocolVersion());
$response->setProtocolVersion('1.1');
$this->assertEquals('1.1', $response->getProtocolVersion());
}
示例4: getProtocolVersion
/**
* Retrieves the HTTP protocol version as a string.
*
* The string MUST contain only the HTTP version number (e.g., "1.1", "1.0").
*
* @return string HTTP protocol version.
*/
public function getProtocolVersion()
{
$this->symfonyResponse->getProtocolVersion();
}
示例5: createResponse
/**
* {@inheritdoc}
*/
public function createResponse(Response $symfonyResponse)
{
if ($symfonyResponse instanceof BinaryFileResponse) {
$stream = new DiactorosStream($symfonyResponse->getFile()->getPathname(), 'r');
} else {
$stream = new DiactorosStream('php://temp', 'wb+');
if ($symfonyResponse instanceof StreamedResponse) {
ob_start(function ($buffer) use($stream) {
$stream->write($buffer);
return false;
});
$symfonyResponse->sendContent();
ob_end_clean();
} else {
$stream->write($symfonyResponse->getContent());
}
}
$headers = $symfonyResponse->headers->all();
$cookies = $symfonyResponse->headers->getCookies();
if (!empty($cookies)) {
$headers['Set-Cookie'] = array();
foreach ($cookies as $cookie) {
$headers['Set-Cookie'][] = $cookie->__toString();
}
}
$response = new DiactorosResponse($stream, $symfonyResponse->getStatusCode(), $headers);
$protocolVersion = $symfonyResponse->getProtocolVersion();
if ('1.1' !== $protocolVersion) {
$response = $response->withProtocolVersion($protocolVersion);
}
return $response;
}
示例6: serializeResponse
/**
* Serialize the response object ready for caching
*
* @param \Symfony\Component\HttpFoundation\Response $response
*
* @return string
*/
public function serializeResponse(Response $response)
{
return array('content' => $response->getContent(), 'headers' => $response->headers, 'version' => $response->getProtocolVersion(), 'statusCode' => $response->getStatusCode(), 'charset' => $response->getCharset());
}
示例7: createContext
/**
* @param Response $response
* @param Request $request
*
* @return array
*/
protected function createContext(Response $response, Request $request)
{
$context = array('response_status_code' => $response->getStatusCode(), 'response_charset' => $response->getCharset(), 'response_date' => $response->getDate(), 'response_etag' => $response->getEtag(), 'response_expires' => $response->getExpires(), 'response_last_modified' => $response->getLastModified(), 'response_max_age' => $response->getMaxAge(), 'response_protocol_version' => $response->getProtocolVersion(), 'response_ttl' => $response->getTtl(), 'response_vary' => $response->getVary(), 'request_method' => $request->getMethod(), 'request_uri' => $request->getRequestUri(), 'request_route' => $request->attributes->get('_route'), 'response_time' => $this->getTime($request), 'response_memory' => $this->getMemory());
return $context;
}