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