From a7b180c911175a62588d25356196762e72754600 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Sat, 8 Oct 2016 20:57:39 -0700 Subject: [PATCH] Remove Empty response. --- lib/src/response/empty.rs | 42 --------------------------------------- lib/src/response/mod.rs | 2 -- 2 files changed, 44 deletions(-) delete mode 100644 lib/src/response/empty.rs diff --git a/lib/src/response/empty.rs b/lib/src/response/empty.rs deleted file mode 100644 index 71d7e8d5..00000000 --- a/lib/src/response/empty.rs +++ /dev/null @@ -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 - } -} diff --git a/lib/src/response/mod.rs b/lib/src/response/mod.rs index f6ce0775..5f616862 100644 --- a/lib/src/response/mod.rs +++ b/lib/src/response/mod.rs @@ -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;