function testCustomStatusResponse() { $this->request->mock(); $this->response->setStatus(320); $this->assertEquals("", $this->send()); $expected = array("HTTP/1.1 320", "Date: " . $this->response->getHeader("Date"), "Content-Length: 0"); $this->assertEquals($expected, HeaderStack::stack()); }
function testIsBodyAllowed() { $response = new Response(); $this->assertTrue($response->isBodyAllowed()); $response->setStatus(101); $this->assertFalse($response->isBodyAllowed()); $response->setStatus(204); $this->assertFalse($response->isBodyAllowed()); $response->setStatus(304); $this->assertFalse($response->isBodyAllowed()); }
/** * Responds to the client to confirm method not allowed. * * @param \stdClass $match * @return void */ protected function routeToNotAllowed($match) { $status = $this->request->getMethod() === "OPTIONS" ? 200 : 405; $this->response->setHeader("Allow", join(", ", $match->allowed)); $this->response->setStatus($status); }