Remove Empty response.

This commit is contained in:
Sergio Benitez 2016-10-08 20:57:39 -07:00
parent 619b1d787e
commit a7b180c911
2 changed files with 0 additions and 44 deletions

View File

@ -1,42 +0,0 @@
use std::io::Write;
use response::{ResponseOutcome, Outcome, Responder};
use http::hyper::{header, FreshHyperResponse};
use http::hyper::StatusCode;
pub struct Empty(StatusCode);
impl Empty {
#[inline(always)]
pub fn new(status: StatusCode) -> Empty {
Empty(status)
}
#[inline(always)]
pub fn not_found() -> Empty {
Empty::new(StatusCode::NotFound)
}
#[inline(always)]
pub fn server_error(reason: &str) -> Empty {
warn_!("internal server error: {}", reason);
Empty::new(StatusCode::InternalServerError)
}
#[inline(always)]
pub fn bad_request(reason: &str) -> Empty {
warn_!("internal server error: {}", reason);
Empty::new(StatusCode::BadRequest)
}
}
impl Responder for Empty {
fn respond<'a>(&mut self, mut res: FreshHyperResponse<'a>) -> ResponseOutcome<'a> {
res.headers_mut().set(header::ContentLength(0));
*(res.status_mut()) = self.0;
let mut stream = res.start().unwrap();
stream.write_all(b"").unwrap();
Outcome::Success
}
}

View File

@ -1,4 +1,3 @@
mod empty;
mod responder;
mod redirect;
mod with_status;
@ -10,7 +9,6 @@ mod failure;
pub mod data;
pub use self::responder::Responder;
pub use self::empty::Empty;
pub use self::redirect::Redirect;
pub use self::with_status::StatusResponse;
pub use self::flash::Flash;