本文整理匯總了PHP中HTTP_Request2_Response::getVersion方法的典型用法代碼示例。如果您正苦於以下問題:PHP HTTP_Request2_Response::getVersion方法的具體用法?PHP HTTP_Request2_Response::getVersion怎麽用?PHP HTTP_Request2_Response::getVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類HTTP_Request2_Response
的用法示例。
在下文中一共展示了HTTP_Request2_Response::getVersion方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testParseStatusLine
/**
*
* @expectedException HTTP_Request2_MessageException
*/
public function testParseStatusLine()
{
$response = new HTTP_Request2_Response('HTTP/1.1 200 OK');
$this->assertEquals('1.1', $response->getVersion());
$this->assertEquals(200, $response->getStatus());
$this->assertEquals('OK', $response->getReasonPhrase());
$response2 = new HTTP_Request2_Response('HTTP/1.2 222 Nishtyak!');
$this->assertEquals('1.2', $response2->getVersion());
$this->assertEquals(222, $response2->getStatus());
$this->assertEquals('Nishtyak!', $response2->getReasonPhrase());
$response3 = new HTTP_Request2_Response('Invalid status line');
}
示例2: testParseStatusLine
public function testParseStatusLine()
{
$response = new HTTP_Request2_Response('HTTP/1.1 200 OK');
$this->assertEquals('1.1', $response->getVersion());
$this->assertEquals(200, $response->getStatus());
$this->assertEquals('OK', $response->getReasonPhrase());
$response2 = new HTTP_Request2_Response('HTTP/1.2 222 Nishtyak!');
$this->assertEquals('1.2', $response2->getVersion());
$this->assertEquals(222, $response2->getStatus());
$this->assertEquals('Nishtyak!', $response2->getReasonPhrase());
try {
$response3 = new HTTP_Request2_Response('Invalid status line');
} catch (HTTP_Request2_Exception $e) {
return;
}
$this->fail('Expected HTTP_Request2_Exception was not thrown');
}
示例3: canKeepAlive
/**
* Checks whether current connection may be reused or should be closed
*
* @param boolean whether connection could be persistent
* in the first place
* @param HTTP_Request2_Response response object to check
* @return boolean
*/
protected function canKeepAlive($requestKeepAlive, HTTP_Request2_Response $response)
{
// Do not close socket on successful CONNECT request
if (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() && 200 <= $response->getStatus() && 300 > $response->getStatus()) {
return true;
}
$lengthKnown = 'chunked' == strtolower($response->getHeader('transfer-encoding')) || null !== $response->getHeader('content-length') || HTTP_Request2::METHOD_HEAD == $this->request->getMethod() || in_array($response->getStatus(), array(204, 304));
$persistent = 'keep-alive' == strtolower($response->getHeader('connection')) || null === $response->getHeader('connection') && '1.1' == $response->getVersion();
return $requestKeepAlive && $lengthKnown && $persistent;
}