/** * Send HTTP response * * This method will set Response headers, set Response cookies, * and `echo` the Response body to the current output buffer. * * @return void */ public function send() { if (!headers_sent()) { $this->sendHeaders(); } if ($this->canHaveBody() && $this->request->isHead() === false) { echo $this->body; } }
/** * Return routes that match the current request * @return array[Slim_Route] */ public function getMatchedRoutes($reload = false) { if ($reload || is_null($this->matchedRoutes)) { $this->matchedRoutes = array(); $method = $this->request->isHead() ? Slim_Http_Request::METHOD_GET : $this->request->getMethod(); foreach ($this->routes[$method] as $route) { if ($route->matches($this->request->getResourceUri())) { $this->matchedRoutes[] = $route; } } } return $this->matchedRoutes; }
/** * Test HTTP HEAD method detection */ public function testIsHead() { $env = Slim_Environment::mock(array('REQUEST_METHOD' => 'HEAD')); $req = new Slim_Http_Request($env); $this->assertFalse($req->isGet()); $this->assertFalse($req->isPost()); $this->assertFalse($req->isPut()); $this->assertFalse($req->isDelete()); $this->assertFalse($req->isOptions()); $this->assertTrue($req->isHead()); }
/** * Test HTTP HEAD method detection */ public function testIsHead() { Slim_Environment::mock(array('REQUEST_METHOD' => 'HEAD', 'REMOTE_ADDR' => '127.0.0.1', 'SCRIPT_NAME' => '/foo/index.php', 'PATH_INFO' => '/bar/xyz', 'QUERY_STRING' => 'one=1&two=2&three=3', 'SERVER_NAME' => 'slim', 'SERVER_PORT' => 80, 'slim.url_scheme' => 'http', 'slim.input' => '', 'slim.errors' => fopen('php://stderr', 'w'))); $env = Slim_Environment::getInstance(); $req = new Slim_Http_Request($env); $this->assertFalse($req->isGet()); $this->assertFalse($req->isPost()); $this->assertFalse($req->isPut()); $this->assertFalse($req->isDelete()); $this->assertFalse($req->isOptions()); $this->assertTrue($req->isHead()); }
public function testIsHead() { $_SERVER['REQUEST_METHOD'] = 'HEAD'; $r = new Slim_Http_Request(); $this->assertTrue($r->isHead()); }