From 5027435791c71e2450a287c07763e15f8df20fa4 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Thu, 28 Sep 2017 18:28:44 -0700 Subject: [PATCH] refactor(lib): rename internal http module to proto --- src/client/mod.rs | 40 +++++++++++----------- src/client/pool.rs | 4 +-- src/header/common/link.rs | 2 +- src/lib.rs | 10 +++--- src/{http => proto}/body.rs | 2 +- src/{http => proto}/chunk.rs | 0 src/{http => proto}/conn.rs | 58 ++++++++++++++++---------------- src/{http => proto}/h1/date.rs | 0 src/{http => proto}/h1/decode.rs | 4 +-- src/{http => proto}/h1/encode.rs | 2 +- src/{http => proto}/h1/mod.rs | 0 src/{http => proto}/h1/parse.rs | 10 +++--- src/{http => proto}/h2/mod.rs | 0 src/{http => proto}/io.rs | 2 +- src/{http => proto}/mod.rs | 0 src/{http => proto}/request.rs | 4 +-- src/{http => proto}/response.rs | 6 ++-- src/server/compat_impl.rs | 6 ++-- src/server/mod.rs | 40 +++++++++++----------- 19 files changed, 95 insertions(+), 95 deletions(-) rename src/{http => proto}/body.rs (99%) rename src/{http => proto}/chunk.rs (100%) rename src/{http => proto}/conn.rs (92%) rename src/{http => proto}/h1/date.rs (100%) rename src/{http => proto}/h1/decode.rs (99%) rename src/{http => proto}/h1/encode.rs (99%) rename src/{http => proto}/h1/mod.rs (100%) rename src/{http => proto}/h1/parse.rs (98%) rename src/{http => proto}/h2/mod.rs (100%) rename src/{http => proto}/io.rs (99%) rename src/{http => proto}/mod.rs (100%) rename src/{http => proto}/request.rs (98%) rename src/{http => proto}/response.rs (97%) diff --git a/src/client/mod.rs b/src/client/mod.rs index e4b26f66..93c0f5a0 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -20,16 +20,16 @@ use tokio_proto::util::client_proxy::ClientProxy; pub use tokio_service::Service; use header::{Headers, Host}; -use http::{self, TokioBody}; -use http::response; -use http::request; +use proto::{self, TokioBody}; +use proto::response; +use proto::request; use method::Method; use self::pool::{Pool, Pooled}; use uri::{self, Uri}; use version::HttpVersion; -pub use http::response::Response; -pub use http::request::Request; +pub use proto::response::Response; +pub use proto::request::Request; pub use self::connect::{HttpConnector, Connect}; mod connect; @@ -42,21 +42,21 @@ pub mod compat; /// A Client to make outgoing HTTP requests. // If the Connector is clone, then the Client can be clone easily. -pub struct Client { +pub struct Client { connector: C, handle: Handle, pool: Pool>, } -impl Client { +impl Client { /// Create a new Client with the default config. #[inline] - pub fn new(handle: &Handle) -> Client { + pub fn new(handle: &Handle) -> Client { Config::default().build(handle) } } -impl Client { +impl Client { /// Configure a Client. /// /// # Example @@ -75,7 +75,7 @@ impl Client { /// # } /// ``` #[inline] - pub fn configure() -> Config { + pub fn configure() -> Config { Config::default() } } @@ -249,7 +249,7 @@ impl fmt::Debug for Client { } } -type TokioClient = ClientProxy, Message, ::Error>; +type TokioClient = ClientProxy, Message, ::Error>; struct HttpClient { client_rx: RefCell>>>>, @@ -260,12 +260,12 @@ where T: AsyncRead + AsyncWrite + 'static, B: Stream + 'static, B::Item: AsRef<[u8]>, { - type Request = http::RequestHead; + type Request = proto::RequestHead; type RequestBody = B::Item; - type Response = http::ResponseHead; - type ResponseBody = http::Chunk; + type Response = proto::ResponseHead; + type ResponseBody = proto::Chunk; type Error = ::Error; - type Transport = http::Conn>>; + type Transport = proto::Conn>>; type BindTransport = BindingClient; fn bind_transport(&self, io: T) -> Self::BindTransport { @@ -286,13 +286,13 @@ where T: AsyncRead + AsyncWrite + 'static, B: Stream, B::Item: AsRef<[u8]>, { - type Item = http::Conn>>; + type Item = proto::Conn>>; type Error = io::Error; fn poll(&mut self) -> Poll { match self.rx.poll() { Ok(Async::Ready(client)) => Ok(Async::Ready( - http::Conn::new(self.io.take().expect("binding client io lost"), client) + proto::Conn::new(self.io.take().expect("binding client io lost"), client) )), Ok(Async::NotReady) => Ok(Async::NotReady), Err(_canceled) => unreachable!(), @@ -315,10 +315,10 @@ pub struct Config { #[derive(Debug, Clone, Copy)] pub struct UseDefaultConnector(()); -impl Default for Config { - fn default() -> Config { +impl Default for Config { + fn default() -> Config { Config { - _body_type: PhantomData::, + _body_type: PhantomData::, //connect_timeout: Duration::from_secs(10), connector: UseDefaultConnector(()), keep_alive: true, diff --git a/src/client/pool.rs b/src/client/pool.rs index 24b39eb7..5ef42a5e 100644 --- a/src/client/pool.rs +++ b/src/client/pool.rs @@ -9,7 +9,7 @@ use std::time::{Duration, Instant}; use futures::{Future, Async, Poll}; use relay; -use http::{KeepAlive, KA}; +use proto::{KeepAlive, KA}; pub struct Pool { inner: Rc>>, @@ -337,7 +337,7 @@ mod tests { use std::time::Duration; use futures::{Async, Future}; use futures::future; - use http::KeepAlive; + use proto::KeepAlive; use super::Pool; #[test] diff --git a/src/header/common/link.rs b/src/header/common/link.rs index 0395801f..8da34ed5 100644 --- a/src/header/common/link.rs +++ b/src/header/common/link.rs @@ -894,7 +894,7 @@ mod tests { use header::Header; - use http::{ServerTransaction, Http1Transaction}; + use proto::{ServerTransaction, Http1Transaction}; use bytes::BytesMut; use mime; diff --git a/src/lib.rs b/src/lib.rs index d7554e07..24424212 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,15 +45,15 @@ pub use uri::Uri; pub use client::Client; pub use error::{Result, Error}; pub use header::Headers; -pub use http::{Body, Chunk}; -pub use http::request::Request; -pub use http::response::Response; +pub use proto::{Body, Chunk}; +pub use proto::request::Request; +pub use proto::response::Response; pub use method::Method::{self, Get, Head, Post, Put, Delete}; pub use status::StatusCode::{self, Ok, BadRequest, NotFound}; pub use server::Server; pub use version::HttpVersion; #[cfg(feature = "raw_status")] -pub use http::RawStatus; +pub use proto::RawStatus; #[cfg(test)] mod mock; @@ -61,7 +61,7 @@ pub mod client; pub mod error; mod method; pub mod header; -mod http; +mod proto; pub mod server; mod status; mod uri; diff --git a/src/http/body.rs b/src/proto/body.rs similarity index 99% rename from src/http/body.rs rename to src/proto/body.rs index 3b490c47..7503ee4c 100644 --- a/src/http/body.rs +++ b/src/proto/body.rs @@ -4,7 +4,7 @@ use futures::sync::mpsc; use tokio_proto; use std::borrow::Cow; -use http::Chunk; +use super::Chunk; pub type TokioBody = tokio_proto::streaming::Body; diff --git a/src/http/chunk.rs b/src/proto/chunk.rs similarity index 100% rename from src/http/chunk.rs rename to src/proto/chunk.rs diff --git a/src/http/conn.rs b/src/proto/conn.rs similarity index 92% rename from src/http/conn.rs rename to src/proto/conn.rs index d3287cd7..63b52704 100644 --- a/src/http/conn.rs +++ b/src/proto/conn.rs @@ -7,9 +7,9 @@ use futures::task::Task; use tokio_io::{AsyncRead, AsyncWrite}; use tokio_proto::streaming::pipeline::{Frame, Transport}; -use http::{self, Http1Transaction}; -use http::io::{Cursor, Buffered}; -use http::h1::{Encoder, Decoder}; +use proto::{Http1Transaction}; +use super::io::{Cursor, Buffered}; +use super::h1::{Encoder, Decoder}; use method::Method; use version::HttpVersion; @@ -51,7 +51,7 @@ where I: AsyncRead + AsyncWrite, self.io.set_flush_pipeline(enabled); } - fn poll2(&mut self) -> Poll, http::Chunk, ::Error>>, io::Error> { + fn poll2(&mut self) -> Poll, super::Chunk, ::Error>>, io::Error> { trace!("Conn::poll()"); loop { @@ -109,7 +109,7 @@ where I: AsyncRead + AsyncWrite, } } - fn read_head(&mut self) -> Poll, http::Chunk, ::Error>>, io::Error> { + fn read_head(&mut self) -> Poll, super::Chunk, ::Error>>, io::Error> { debug_assert!(self.can_read_head()); trace!("Conn::read_head"); @@ -164,7 +164,7 @@ where I: AsyncRead + AsyncWrite, } } - fn read_body(&mut self) -> Poll, io::Error> { + fn read_body(&mut self) -> Poll, io::Error> { debug_assert!(self.can_read_body()); trace!("Conn::read_body"); @@ -173,7 +173,7 @@ where I: AsyncRead + AsyncWrite, Reading::Body(ref mut decoder) => { let slice = try_ready!(decoder.decode(&mut self.io)); if !slice.is_empty() { - return Ok(Async::Ready(Some(http::Chunk::from(slice)))); + return Ok(Async::Ready(Some(super::Chunk::from(slice)))); } else if decoder.is_eof() { (Reading::KeepAlive, Ok(Async::Ready(None))) } else { @@ -277,7 +277,7 @@ where I: AsyncRead + AsyncWrite, } } - fn write_head(&mut self, head: http::MessageHead, body: bool) { + fn write_head(&mut self, head: super::MessageHead, body: bool) { debug_assert!(self.can_write_head()); let wants_keep_alive = head.should_keep_alive(); @@ -418,7 +418,7 @@ where I: AsyncRead + AsyncWrite, T: Http1Transaction, K: KeepAlive, T::Outgoing: fmt::Debug { - type Item = Frame, http::Chunk, ::Error>; + type Item = Frame, super::Chunk, ::Error>; type Error = io::Error; #[inline] @@ -436,7 +436,7 @@ where I: AsyncRead + AsyncWrite, T: Http1Transaction, K: KeepAlive, T::Outgoing: fmt::Debug { - type SinkItem = Frame, B, ::Error>; + type SinkItem = Frame, B, ::Error>; type SinkError = io::Error; #[inline] @@ -692,7 +692,7 @@ impl State { // The DebugFrame and DebugChunk are simple Debug implementations that allow // us to dump the frame into logs, without logging the entirety of the bytes. -struct DebugFrame<'a, T: fmt::Debug + 'a, B: AsRef<[u8]> + 'a>(&'a Frame, B, ::Error>); +struct DebugFrame<'a, T: fmt::Debug + 'a, B: AsRef<[u8]> + 'a>(&'a Frame, B, ::Error>); impl<'a, T: fmt::Debug + 'a, B: AsRef<[u8]> + 'a> fmt::Debug for DebugFrame<'a, T, B> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -727,8 +727,8 @@ mod tests { use futures::future; use tokio_proto::streaming::pipeline::Frame; - use http::{self, MessageHead, ServerTransaction}; - use http::h1::Encoder; + use proto::{self, MessageHead, ServerTransaction}; + use super::super::h1::Encoder; use mock::AsyncIo; use super::{Conn, Reading, Writing}; @@ -750,12 +750,12 @@ mod tests { let good_message = b"GET / HTTP/1.1\r\n\r\n".to_vec(); let len = good_message.len(); let io = AsyncIo::new_buf(good_message, len); - let mut conn = Conn::<_, http::Chunk, ServerTransaction>::new(io, Default::default()); + let mut conn = Conn::<_, proto::Chunk, ServerTransaction>::new(io, Default::default()); match conn.poll().unwrap() { Async::Ready(Some(Frame::Message { message, body: false })) => { assert_eq!(message, MessageHead { - subject: ::http::RequestLine(::Get, Uri::from_str("/").unwrap()), + subject: ::proto::RequestLine(::Get, Uri::from_str("/").unwrap()), .. MessageHead::default() }) }, @@ -768,7 +768,7 @@ mod tests { let _: Result<(), ()> = future::lazy(|| { let good_message = b"GET / HTTP/1.1\r\nHost: foo.bar\r\n\r\n".to_vec(); let io = AsyncIo::new_buf(good_message, 10); - let mut conn = Conn::<_, http::Chunk, ServerTransaction>::new(io, Default::default()); + let mut conn = Conn::<_, proto::Chunk, ServerTransaction>::new(io, Default::default()); assert!(conn.poll().unwrap().is_not_ready()); conn.io.io_mut().block_in(50); let async = conn.poll().unwrap(); @@ -784,7 +784,7 @@ mod tests { #[test] fn test_conn_init_read_eof_idle() { let io = AsyncIo::new_buf(vec![], 1); - let mut conn = Conn::<_, http::Chunk, ServerTransaction>::new(io, Default::default()); + let mut conn = Conn::<_, proto::Chunk, ServerTransaction>::new(io, Default::default()); conn.state.idle(); match conn.poll().unwrap() { @@ -796,7 +796,7 @@ mod tests { #[test] fn test_conn_init_read_eof_idle_partial_parse() { let io = AsyncIo::new_buf(b"GET / HTTP/1.1".to_vec(), 100); - let mut conn = Conn::<_, http::Chunk, ServerTransaction>::new(io, Default::default()); + let mut conn = Conn::<_, proto::Chunk, ServerTransaction>::new(io, Default::default()); conn.state.idle(); match conn.poll().unwrap() { @@ -808,7 +808,7 @@ mod tests { #[test] fn test_conn_init_read_eof_busy() { let io = AsyncIo::new_buf(vec![], 1); - let mut conn = Conn::<_, http::Chunk, ServerTransaction>::new(io, Default::default()); + let mut conn = Conn::<_, proto::Chunk, ServerTransaction>::new(io, Default::default()); conn.state.busy(); match conn.poll().unwrap() { @@ -820,7 +820,7 @@ mod tests { #[test] fn test_conn_closed_read() { let io = AsyncIo::new_buf(vec![], 0); - let mut conn = Conn::<_, http::Chunk, ServerTransaction>::new(io, Default::default()); + let mut conn = Conn::<_, proto::Chunk, ServerTransaction>::new(io, Default::default()); conn.state.close(); match conn.poll().unwrap() { @@ -835,8 +835,8 @@ mod tests { let _ = pretty_env_logger::init(); let _: Result<(), ()> = future::lazy(|| { let io = AsyncIo::new_buf(vec![], 0); - let mut conn = Conn::<_, http::Chunk, ServerTransaction>::new(io, Default::default()); - let max = ::http::io::MAX_BUFFER_SIZE + 4096; + let mut conn = Conn::<_, proto::Chunk, ServerTransaction>::new(io, Default::default()); + let max = ::proto::io::MAX_BUFFER_SIZE + 4096; conn.state.writing = Writing::Body(Encoder::length((max * 2) as u64), None); assert!(conn.start_send(Frame::Body { chunk: Some(vec![b'a'; 1024 * 8].into()) }).unwrap().is_ready()); @@ -863,7 +863,7 @@ mod tests { fn test_conn_body_write_chunked() { let _: Result<(), ()> = future::lazy(|| { let io = AsyncIo::new_buf(vec![], 4096); - let mut conn = Conn::<_, http::Chunk, ServerTransaction>::new(io, Default::default()); + let mut conn = Conn::<_, proto::Chunk, ServerTransaction>::new(io, Default::default()); conn.state.writing = Writing::Body(Encoder::chunked(), None); assert!(conn.start_send(Frame::Body { chunk: Some("headers".into()) }).unwrap().is_ready()); @@ -876,7 +876,7 @@ mod tests { fn test_conn_body_flush() { let _: Result<(), ()> = future::lazy(|| { let io = AsyncIo::new_buf(vec![], 1024 * 1024 * 5); - let mut conn = Conn::<_, http::Chunk, ServerTransaction>::new(io, Default::default()); + let mut conn = Conn::<_, proto::Chunk, ServerTransaction>::new(io, Default::default()); conn.state.writing = Writing::Body(Encoder::length(1024 * 1024), None); assert!(conn.start_send(Frame::Body { chunk: Some(vec![b'a'; 1024 * 1024].into()) }).unwrap().is_ready()); assert!(conn.state.writing.is_queued()); @@ -912,7 +912,7 @@ mod tests { // test that once writing is done, unparks let f = future::lazy(|| { let io = AsyncIo::new_buf(vec![], 4096); - let mut conn = Conn::<_, http::Chunk, ServerTransaction>::new(io, Default::default()); + let mut conn = Conn::<_, proto::Chunk, ServerTransaction>::new(io, Default::default()); conn.state.reading = Reading::KeepAlive; assert!(conn.poll().unwrap().is_not_ready()); @@ -926,7 +926,7 @@ mod tests { // test that flushing when not waiting on read doesn't unpark let f = future::lazy(|| { let io = AsyncIo::new_buf(vec![], 4096); - let mut conn = Conn::<_, http::Chunk, ServerTransaction>::new(io, Default::default()); + let mut conn = Conn::<_, proto::Chunk, ServerTransaction>::new(io, Default::default()); conn.state.writing = Writing::KeepAlive; assert!(conn.poll_complete().unwrap().is_ready()); Ok::<(), ()>(()) @@ -937,7 +937,7 @@ mod tests { // test that flushing and writing isn't done doesn't unpark let f = future::lazy(|| { let io = AsyncIo::new_buf(vec![], 4096); - let mut conn = Conn::<_, http::Chunk, ServerTransaction>::new(io, Default::default()); + let mut conn = Conn::<_, proto::Chunk, ServerTransaction>::new(io, Default::default()); conn.state.reading = Reading::KeepAlive; assert!(conn.poll().unwrap().is_not_ready()); conn.state.writing = Writing::Body(Encoder::length(5_000), None); @@ -950,7 +950,7 @@ mod tests { #[test] fn test_conn_closed_write() { let io = AsyncIo::new_buf(vec![], 0); - let mut conn = Conn::<_, http::Chunk, ServerTransaction>::new(io, Default::default()); + let mut conn = Conn::<_, proto::Chunk, ServerTransaction>::new(io, Default::default()); conn.state.close(); match conn.start_send(Frame::Body { chunk: Some(b"foobar".to_vec().into()) }) { @@ -964,7 +964,7 @@ mod tests { #[test] fn test_conn_write_empty_chunk() { let io = AsyncIo::new_buf(vec![], 0); - let mut conn = Conn::<_, http::Chunk, ServerTransaction>::new(io, Default::default()); + let mut conn = Conn::<_, proto::Chunk, ServerTransaction>::new(io, Default::default()); conn.state.writing = Writing::KeepAlive; assert!(conn.start_send(Frame::Body { chunk: None }).unwrap().is_ready()); diff --git a/src/http/h1/date.rs b/src/proto/h1/date.rs similarity index 100% rename from src/http/h1/date.rs rename to src/proto/h1/date.rs diff --git a/src/http/h1/decode.rs b/src/proto/h1/decode.rs similarity index 99% rename from src/http/h1/decode.rs rename to src/proto/h1/decode.rs index 11438239..ea6227da 100644 --- a/src/http/h1/decode.rs +++ b/src/proto/h1/decode.rs @@ -3,7 +3,7 @@ use std::io; use futures::{Async, Poll}; use bytes::Bytes; -use http::io::MemRead; +use proto::io::MemRead; use self::Kind::{Length, Chunked, Eof}; @@ -281,7 +281,7 @@ mod tests { use std::io::Write; use super::Decoder; use super::ChunkedState; - use http::io::MemRead; + use proto::io::MemRead; use futures::{Async, Poll}; use bytes::{BytesMut, Bytes}; use mock::AsyncIo; diff --git a/src/http/h1/encode.rs b/src/proto/h1/encode.rs similarity index 99% rename from src/http/h1/encode.rs rename to src/proto/h1/encode.rs index 1f062663..5033eba5 100644 --- a/src/http/h1/encode.rs +++ b/src/proto/h1/encode.rs @@ -1,7 +1,7 @@ use std::cmp; use std::io::{self, Write}; -use http::io::AtomicWrite; +use proto::io::AtomicWrite; /// Encoders to handle different Transfer-Encodings. #[derive(Debug, Clone)] diff --git a/src/http/h1/mod.rs b/src/proto/h1/mod.rs similarity index 100% rename from src/http/h1/mod.rs rename to src/proto/h1/mod.rs diff --git a/src/http/h1/parse.rs b/src/proto/h1/parse.rs similarity index 98% rename from src/http/h1/parse.rs rename to src/proto/h1/parse.rs index 6d7b2f03..001be5f7 100644 --- a/src/http/h1/parse.rs +++ b/src/proto/h1/parse.rs @@ -5,9 +5,9 @@ use httparse; use bytes::{BytesMut, Bytes}; use header::{self, Headers, ContentLength, TransferEncoding}; -use http::{MessageHead, RawStatus, Http1Transaction, ParseResult, +use proto::{MessageHead, RawStatus, Http1Transaction, ParseResult, ServerTransaction, ClientTransaction, RequestLine, RequestHead}; -use http::h1::{Encoder, Decoder, date}; +use proto::h1::{Encoder, Decoder, date}; use method::Method; use status::StatusCode; use version::HttpVersion::{Http10, Http11}; @@ -381,7 +381,7 @@ fn extend(dst: &mut Vec, data: &[u8]) { mod tests { use bytes::BytesMut; - use http::{MessageHead, ServerTransaction, ClientTransaction, Http1Transaction}; + use proto::{MessageHead, ServerTransaction, ClientTransaction, Http1Transaction}; use header::{ContentLength, TransferEncoding}; #[test] @@ -438,7 +438,7 @@ mod tests { use super::Decoder; let method = &mut None; - let mut head = MessageHead::<::http::RequestLine>::default(); + let mut head = MessageHead::<::proto::RequestLine>::default(); head.subject.0 = ::Method::Get; assert_eq!(Decoder::length(0), ServerTransaction::decoder(&head, method).unwrap()); @@ -474,7 +474,7 @@ mod tests { use super::Decoder; let method = &mut Some(::Method::Get); - let mut head = MessageHead::<::http::RawStatus>::default(); + let mut head = MessageHead::<::proto::RawStatus>::default(); head.subject.0 = 204; assert_eq!(Decoder::length(0), ClientTransaction::decoder(&head, method).unwrap()); diff --git a/src/http/h2/mod.rs b/src/proto/h2/mod.rs similarity index 100% rename from src/http/h2/mod.rs rename to src/proto/h2/mod.rs diff --git a/src/http/io.rs b/src/proto/io.rs similarity index 99% rename from src/http/io.rs rename to src/proto/io.rs index be58a4a2..ed30173d 100644 --- a/src/http/io.rs +++ b/src/proto/io.rs @@ -6,7 +6,7 @@ use std::ptr; use futures::{Async, Poll}; use tokio_io::{AsyncRead, AsyncWrite}; -use http::{Http1Transaction, MessageHead}; +use super::{Http1Transaction, MessageHead}; use bytes::{BytesMut, Bytes}; const INIT_BUFFER_SIZE: usize = 8192; diff --git a/src/http/mod.rs b/src/proto/mod.rs similarity index 100% rename from src/http/mod.rs rename to src/proto/mod.rs diff --git a/src/http/request.rs b/src/proto/request.rs similarity index 98% rename from src/http/request.rs rename to src/proto/request.rs index f8f68d46..b9a7e5a5 100644 --- a/src/http/request.rs +++ b/src/proto/request.rs @@ -7,7 +7,7 @@ use std::net::SocketAddr; use http_types; use header::Headers; -use http::{Body, MessageHead, RequestHead, RequestLine}; +use proto::{Body, MessageHead, RequestHead, RequestLine}; use method::Method; use uri::{self, Uri}; use version::HttpVersion; @@ -189,7 +189,7 @@ pub fn split(req: Request) -> (RequestHead, Option) { uri::origin_form(&req.uri) }; let head = RequestHead { - subject: ::http::RequestLine(req.method, uri), + subject: ::proto::RequestLine(req.method, uri), headers: req.headers, version: req.version, }; diff --git a/src/http/response.rs b/src/proto/response.rs similarity index 97% rename from src/http/response.rs rename to src/proto/response.rs index c96facd0..5d590099 100644 --- a/src/http/response.rs +++ b/src/proto/response.rs @@ -6,7 +6,7 @@ use std::mem::replace; use http_types; use header::{Header, Headers}; -use http::{MessageHead, ResponseHead, Body}; +use proto::{MessageHead, ResponseHead, Body}; use status::StatusCode; use version::HttpVersion; @@ -16,7 +16,7 @@ pub struct Response { headers: Headers, status: StatusCode, #[cfg(feature = "raw_status")] - raw_status: ::http::RawStatus, + raw_status: ::proto::RawStatus, body: Option, } @@ -49,7 +49,7 @@ impl Response { /// a received response. #[inline] #[cfg(feature = "raw_status")] - pub fn status_raw(&self) -> &::http::RawStatus { &self.raw_status } + pub fn status_raw(&self) -> &::proto::RawStatus { &self.raw_status } /// Set the `StatusCode` for this response. #[inline] diff --git a/src/server/compat_impl.rs b/src/server/compat_impl.rs index 4bf596cd..65660423 100644 --- a/src/server/compat_impl.rs +++ b/src/server/compat_impl.rs @@ -5,9 +5,9 @@ use http_types; use tokio_service::{NewService, Service}; use error::Error; -use http::Body; -use http::request::Request; -use http::response::Response; +use proto::Body; +use proto::request::Request; +use proto::response::Response; /// Wraps a `Future` returning an `http::Response` into /// a `Future` returning a `hyper::server::Response`. diff --git a/src/server/mod.rs b/src/server/mod.rs index 99602944..c36b3722 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -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 fmt::Debug for Http { #[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(http::Conn); +pub struct __ProtoTransport(proto::Conn); #[doc(hidden)] #[allow(missing_debug_implementations)] pub struct __ProtoBindTransport { - inner: future::FutureResult, io::Error>, + inner: future::FutureResult, io::Error>, } impl ServerProto for Http @@ -222,7 +222,7 @@ impl ServerProto for Http 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 ServerProto for Http #[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 Stream for __ProtoTransport 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 Future for __ProtoBindTransport } } -impl From> for Request { +impl From> 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 { remote_addr: SocketAddr, } -type ResponseHead = http::MessageHead<::StatusCode>; +type ResponseHead = proto::MessageHead<::StatusCode>; impl Service for HttpService where T: Service, Error=::Error>, B: Stream, 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) -> Message<__ProtoResponse, B>>; @@ -383,7 +383,7 @@ impl Service for HttpService #[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);