Esempio n. 1
0
 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());
 }
Esempio n. 2
0
 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());
 }
Esempio n. 3
0
 /**
  * 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);
 }