Ejemplo n.º 1
0
 public function testCreateRequestFromFullString()
 {
     $r = new Request();
     $r->createFromString("GET / HTTP/1.1\r\nserver: localhost\r\nuser-agent: phpunit\r\n\r\n");
     $this->assertTrue($r->isRequestComplete());
     $this->assertEquals($r->getRequestUrl(), "/");
     $this->assertEquals($r->getRequestMethod(), "GET");
     $this->assertEquals($r->getRequestProtocol(), "HTTP/1.1");
     $this->assertEquals($r->getHeader("server"), "localhost");
     $this->assertEquals($r->getHeader("user-agent"), "phpunit");
 }
Ejemplo n.º 2
0
 function logHit(Request $req, Response $resp)
 {
     $log = sprintf("%15s [%s (%s)] %d %s %s %s", date("d-M-y h:i:s", $req->getTimestamp()), $req->getRemoteIp(), $req->getRemoteHost(), $resp->getStatus(), $req->getRequestMethod(), $req->getRequestURL(), $resp->contentLength ? "(" . $resp->contentLength . " bytes)" : "");
     fprintf(STDERR, $log . "\n");
 }