diff --git a/src/client/mod.rs b/src/client/mod.rs
index d8cec11c..2ea07e6a 100644
--- a/src/client/mod.rs
+++ b/src/client/mod.rs
@@ -22,19 +22,19 @@ pub use tokio_service::Service;
use header::{Headers, Host};
use http::{self, TokioBody};
+use http::response;
+use http::request;
use method::Method;
use self::pool::{Pool, Pooled};
use uri::{self, Uri};
+pub use http::response::Response;
+pub use http::request::Request;
pub use self::connect::{HttpConnector, Connect};
-pub use self::request::Request;
-pub use self::response::Response;
mod connect;
mod dns;
mod pool;
-mod request;
-mod response;
/// A Client to make outgoing HTTP requests.
// If the Connector is clone, then the Client can be clone easily.
@@ -198,8 +198,8 @@ where C: Connect,
});
FutureResponse(Box::new(req.map(|msg| {
match msg {
- Message::WithoutBody(head) => response::new(head, None),
- Message::WithBody(head, body) => response::new(head, Some(body.into())),
+ Message::WithoutBody(head) => response::from_wire(head, None),
+ Message::WithBody(head, body) => response::from_wire(head, Some(body.into())),
}
})))
}
diff --git a/src/client/response.rs b/src/client/response.rs
deleted file mode 100644
index 3db0ae13..00000000
--- a/src/client/response.rs
+++ /dev/null
@@ -1,65 +0,0 @@
-use std::fmt;
-
-use header;
-use http::{self, RawStatus, Body};
-use status;
-use version;
-
-pub fn new(incoming: http::ResponseHead, body: Option
) -> Response {
- trace!("Response::new");
- let status = status::StatusCode::from_u16(incoming.subject.0);
- debug!("version={:?}, status={:?}", incoming.version, status);
- debug!("headers={:?}", incoming.headers);
-
- Response {
- status: status,
- version: incoming.version,
- headers: incoming.headers,
- status_raw: incoming.subject,
- body: body,
- }
-
-}
-
-/// A response for a client request to a remote server.
-pub struct Response {
- status: status::StatusCode,
- headers: header::Headers,
- version: version::HttpVersion,
- status_raw: RawStatus,
- body: Option,
-}
-
-impl Response {
- /// Get the headers from the server.
- #[inline]
- pub fn headers(&self) -> &header::Headers { &self.headers }
-
- /// Get the status from the server.
- #[inline]
- pub fn status(&self) -> status::StatusCode { self.status }
-
- /// Get the raw status code and reason.
- #[inline]
- pub fn status_raw(&self) -> &RawStatus { &self.status_raw }
-
- /// Get the HTTP version of this response from the server.
- #[inline]
- pub fn version(&self) -> version::HttpVersion { self.version }
-
- /// Take the `Body` of this response.
- #[inline]
- pub fn body(mut self) -> Body {
- self.body.take().unwrap_or(Body::empty())
- }
-}
-
-impl fmt::Debug for Response {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.debug_struct("Response")
- .field("status", &self.status)
- .field("version", &self.version)
- .field("headers", &self.headers)
- .finish()
- }
-}
diff --git a/src/http/body.rs b/src/http/body.rs
index 0ece860e..e454b22b 100644
--- a/src/http/body.rs
+++ b/src/http/body.rs
@@ -34,12 +34,6 @@ impl Default for Body {
}
}
-impl Default for Body {
- fn default() -> Body {
- Body::empty()
- }
-}
-
impl Stream for Body {
type Item = Chunk;
type Error = ::Error;
@@ -114,6 +108,7 @@ impl From<&'static str> for Body {
}
impl From