refactor(lib): rename internal http module to proto

This commit is contained in:
Sean McArthur
2017-09-28 18:28:44 -07:00
parent 217941cef2
commit 5027435791
19 changed files with 95 additions and 95 deletions

View File

@@ -32,14 +32,14 @@ use tokio_proto::streaming::Message;
use tokio_proto::streaming::pipeline::{Transport, Frame, ServerProto};
pub use tokio_service::{NewService, Service};
use http;
use http::response;
use http::request;
use proto;
use proto::response;
use proto::request;
#[cfg(feature = "compat")]
use http::Body;
use proto::Body;
pub use http::response::Response;
pub use http::request::Request;
pub use proto::response::Response;
pub use proto::request::Request;
/// An instance of the HTTP protocol, and implementation of tokio-proto's
/// `ServerProto` trait.
@@ -204,17 +204,17 @@ impl<B> fmt::Debug for Http<B> {
#[doc(hidden)]
#[allow(missing_debug_implementations)]
pub struct __ProtoRequest(http::RequestHead);
pub struct __ProtoRequest(proto::RequestHead);
#[doc(hidden)]
#[allow(missing_debug_implementations)]
pub struct __ProtoResponse(ResponseHead);
#[doc(hidden)]
#[allow(missing_debug_implementations)]
pub struct __ProtoTransport<T, B>(http::Conn<T, B, http::ServerTransaction>);
pub struct __ProtoTransport<T, B>(proto::Conn<T, B, proto::ServerTransaction>);
#[doc(hidden)]
#[allow(missing_debug_implementations)]
pub struct __ProtoBindTransport<T, B> {
inner: future::FutureResult<http::Conn<T, B, http::ServerTransaction>, io::Error>,
inner: future::FutureResult<proto::Conn<T, B, proto::ServerTransaction>, io::Error>,
}
impl<T, B> ServerProto<T> for Http<B>
@@ -222,7 +222,7 @@ impl<T, B> ServerProto<T> for Http<B>
B: AsRef<[u8]> + 'static,
{
type Request = __ProtoRequest;
type RequestBody = http::Chunk;
type RequestBody = proto::Chunk;
type Response = __ProtoResponse;
type ResponseBody = B;
type Error = ::Error;
@@ -232,11 +232,11 @@ impl<T, B> ServerProto<T> for Http<B>
#[inline]
fn bind_transport(&self, io: T) -> Self::BindTransport {
let ka = if self.keep_alive {
http::KA::Busy
proto::KA::Busy
} else {
http::KA::Disabled
proto::KA::Disabled
};
let mut conn = http::Conn::new(io, ka);
let mut conn = proto::Conn::new(io, ka);
conn.set_flush_pipeline(self.pipeline);
__ProtoBindTransport {
inner: future::ok(conn),
@@ -293,7 +293,7 @@ impl<T, B> Stream for __ProtoTransport<T, B>
where T: AsyncRead + AsyncWrite + 'static,
B: AsRef<[u8]> + 'static,
{
type Item = Frame<__ProtoRequest, http::Chunk, ::Error>;
type Item = Frame<__ProtoRequest, proto::Chunk, ::Error>;
type Error = io::Error;
#[inline]
@@ -340,11 +340,11 @@ impl<T, B> Future for __ProtoBindTransport<T, B>
}
}
impl From<Message<__ProtoRequest, http::TokioBody>> for Request {
impl From<Message<__ProtoRequest, proto::TokioBody>> for Request {
#[inline]
fn from(message: Message<__ProtoRequest, http::TokioBody>) -> Request {
fn from(message: Message<__ProtoRequest, proto::TokioBody>) -> Request {
let (head, body) = match message {
Message::WithoutBody(head) => (head.0, http::Body::empty()),
Message::WithoutBody(head) => (head.0, proto::Body::empty()),
Message::WithBody(head, body) => (head.0, body.into()),
};
request::from_wire(None, head, body)
@@ -368,14 +368,14 @@ struct HttpService<T> {
remote_addr: SocketAddr,
}
type ResponseHead = http::MessageHead<::StatusCode>;
type ResponseHead = proto::MessageHead<::StatusCode>;
impl<T, B> Service for HttpService<T>
where T: Service<Request=Request, Response=Response<B>, Error=::Error>,
B: Stream<Error=::Error>,
B::Item: AsRef<[u8]>,
{
type Request = Message<__ProtoRequest, http::TokioBody>;
type Request = Message<__ProtoRequest, proto::TokioBody>;
type Response = Message<__ProtoResponse, B>;
type Error = ::Error;
type Future = Map<T::Future, fn(Response<B>) -> Message<__ProtoResponse, B>>;
@@ -383,7 +383,7 @@ impl<T, B> Service for HttpService<T>
#[inline]
fn call(&self, message: Self::Request) -> Self::Future {
let (head, body) = match message {
Message::WithoutBody(head) => (head.0, http::Body::empty()),
Message::WithoutBody(head) => (head.0, proto::Body::empty()),
Message::WithBody(head, body) => (head.0, body.into()),
};
let req = request::from_wire(Some(self.remote_addr), head, body);