function test_is_redirection() { $this->assertFalse(No2_HTTP::is_redirection(299)); // before inf limit $this->assertTrue(No2_HTTP::is_redirection(301)); // inferior limit $this->assertTrue(No2_HTTP::is_redirection(304)); // mid. $this->assertTrue(No2_HTTP::is_redirection(308)); // superior limit $this->assertFalse(No2_HTTP::is_redirection(400)); // after sup limit }
/** * redirect to the given location. * * * This method is designed to be called from the controller. * * @param $location * An URI string, the location to redirect to. * * @param $status * The HTTP status code. It should be a redirect status code. The default * is 303 See Other as this method is intended to be used by action * methods modifying the database by POST requests. * (see http://en.wikipedia.org/wiki/HTTP_303) */ public function redirect_to($location, $status = No2_HTTP::SEE_OTHER) { if (No2_HTTP::is_redirection($status)) { $this->set_status($status); } $this->__redirect_location = $location; // prepare the flash for the next call. if (session_active()) { $_SESSION['_no2_flash'] = $this->flash; } }