示例#1
0
 function testSendCookies()
 {
     $cookie = new Cookie("name", "value");
     $this->response->addCookie($cookie);
     $this->request->mock();
     $this->send();
     $expected = array("HTTP/1.1 200 OK", "Date: " . $this->response->getHeader("Date"), "Content-Length: 0", "Set-Cookie: " . $cookie);
     $this->assertEquals($expected, HeaderStack::stack());
 }
示例#2
0
文件: Api.php 项目: rawebone/wilson
 /**
  * Provides a minimal default not found response, emitting a HTTP Status 404
  * and writing "Not Found" to the User Agent.
  *
  * @param Request $request
  * @param Response $response
  * @return void
  */
 public function defaultNotFound(Request $request, Response $response)
 {
     $response->html("<b>Not Found</b>", 404);
 }
示例#3
0
 function testNoCacheControlWhenEmpty()
 {
     $this->cacheControl->makeCacheHeaders();
     $this->assertNull($this->response->getHeader("Cache-Control"));
 }
示例#4
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());
 }
示例#5
0
 function testMethodNotAllowedDispatch()
 {
     $this->request->mock(array("REQUEST_URI" => "/route-1", "REQUEST_METHOD" => "POST"));
     $this->assertEmpty($this->dispatch());
     $this->assertEquals(405, $this->response->getStatus());
 }
示例#6
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);
 }
示例#7
0
 function fail(Request $request, Response $response)
 {
     $response->setBody("failed");
     return false;
 }