SimpleHttpRequest::fetch PHP Method

fetch() public method

Dispatches the content to the route's socket.
public fetch ( integer $timeout ) : SimpleHttpResponse
$timeout integer Connection timeout.
return SimpleHttpResponse A response which may only have an error, but hopefully has a complete web page.
    public function fetch($timeout)
    {
        $socket = $this->route->createConnection($this->encoding->getMethod(), $timeout);
        if (!$socket->isError()) {
            $this->dispatchRequest($socket, $this->encoding);
        }
        return $this->createResponse($socket);
    }

Usage Example

示例#1
0
 function testHttp()
 {
     $http = new SimpleHttpRequest("www.lastcraft.com/test/network_confirm.php?gkey=gvalue");
     $http->setCookie(new SimpleCookie("ckey", "cvalue"));
     $this->assertIsA($reponse = $http->fetch(), "SimpleHttpResponse");
     $this->assertEqual($reponse->getResponseCode(), 200);
     $this->assertEqual($reponse->getMimeType(), "text/html");
     $this->assertWantedPattern('/A target for the SimpleTest test suite/', $reponse->getContent());
     $this->assertWantedPattern('/gkey=gvalue/', $reponse->getContent());
     $this->assertWantedPattern('/ckey=cvalue/', $reponse->getContent());
 }
All Usage Examples Of SimpleHttpRequest::fetch