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

@@ -20,16 +20,16 @@ use tokio_proto::util::client_proxy::ClientProxy;
pub use tokio_service::Service; pub use tokio_service::Service;
use header::{Headers, Host}; use header::{Headers, Host};
use http::{self, TokioBody}; use proto::{self, TokioBody};
use http::response; use proto::response;
use http::request; use proto::request;
use method::Method; use method::Method;
use self::pool::{Pool, Pooled}; use self::pool::{Pool, Pooled};
use uri::{self, Uri}; use uri::{self, Uri};
use version::HttpVersion; use version::HttpVersion;
pub use http::response::Response; pub use proto::response::Response;
pub use http::request::Request; pub use proto::request::Request;
pub use self::connect::{HttpConnector, Connect}; pub use self::connect::{HttpConnector, Connect};
mod connect; mod connect;
@@ -42,21 +42,21 @@ pub mod compat;
/// A Client to make outgoing HTTP requests. /// A Client to make outgoing HTTP requests.
// If the Connector is clone, then the Client can be clone easily. // If the Connector is clone, then the Client can be clone easily.
pub struct Client<C, B = http::Body> { pub struct Client<C, B = proto::Body> {
connector: C, connector: C,
handle: Handle, handle: Handle,
pool: Pool<TokioClient<B>>, pool: Pool<TokioClient<B>>,
} }
impl Client<HttpConnector, http::Body> { impl Client<HttpConnector, proto::Body> {
/// Create a new Client with the default config. /// Create a new Client with the default config.
#[inline] #[inline]
pub fn new(handle: &Handle) -> Client<HttpConnector, http::Body> { pub fn new(handle: &Handle) -> Client<HttpConnector, proto::Body> {
Config::default().build(handle) Config::default().build(handle)
} }
} }
impl Client<HttpConnector, http::Body> { impl Client<HttpConnector, proto::Body> {
/// Configure a Client. /// Configure a Client.
/// ///
/// # Example /// # Example
@@ -75,7 +75,7 @@ impl Client<HttpConnector, http::Body> {
/// # } /// # }
/// ``` /// ```
#[inline] #[inline]
pub fn configure() -> Config<UseDefaultConnector, http::Body> { pub fn configure() -> Config<UseDefaultConnector, proto::Body> {
Config::default() Config::default()
} }
} }
@@ -249,7 +249,7 @@ impl<C, B> fmt::Debug for Client<C, B> {
} }
} }
type TokioClient<B> = ClientProxy<Message<http::RequestHead, B>, Message<http::ResponseHead, TokioBody>, ::Error>; type TokioClient<B> = ClientProxy<Message<proto::RequestHead, B>, Message<proto::ResponseHead, TokioBody>, ::Error>;
struct HttpClient<B> { struct HttpClient<B> {
client_rx: RefCell<Option<oneshot::Receiver<Pooled<TokioClient<B>>>>>, client_rx: RefCell<Option<oneshot::Receiver<Pooled<TokioClient<B>>>>>,
@@ -260,12 +260,12 @@ where T: AsyncRead + AsyncWrite + 'static,
B: Stream<Error=::Error> + 'static, B: Stream<Error=::Error> + 'static,
B::Item: AsRef<[u8]>, B::Item: AsRef<[u8]>,
{ {
type Request = http::RequestHead; type Request = proto::RequestHead;
type RequestBody = B::Item; type RequestBody = B::Item;
type Response = http::ResponseHead; type Response = proto::ResponseHead;
type ResponseBody = http::Chunk; type ResponseBody = proto::Chunk;
type Error = ::Error; type Error = ::Error;
type Transport = http::Conn<T, B::Item, http::ClientTransaction, Pooled<TokioClient<B>>>; type Transport = proto::Conn<T, B::Item, proto::ClientTransaction, Pooled<TokioClient<B>>>;
type BindTransport = BindingClient<T, B>; type BindTransport = BindingClient<T, B>;
fn bind_transport(&self, io: T) -> Self::BindTransport { fn bind_transport(&self, io: T) -> Self::BindTransport {
@@ -286,13 +286,13 @@ where T: AsyncRead + AsyncWrite + 'static,
B: Stream<Error=::Error>, B: Stream<Error=::Error>,
B::Item: AsRef<[u8]>, B::Item: AsRef<[u8]>,
{ {
type Item = http::Conn<T, B::Item, http::ClientTransaction, Pooled<TokioClient<B>>>; type Item = proto::Conn<T, B::Item, proto::ClientTransaction, Pooled<TokioClient<B>>>;
type Error = io::Error; type Error = io::Error;
fn poll(&mut self) -> Poll<Self::Item, Self::Error> { fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
match self.rx.poll() { match self.rx.poll() {
Ok(Async::Ready(client)) => Ok(Async::Ready( 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), Ok(Async::NotReady) => Ok(Async::NotReady),
Err(_canceled) => unreachable!(), Err(_canceled) => unreachable!(),
@@ -315,10 +315,10 @@ pub struct Config<C, B> {
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub struct UseDefaultConnector(()); pub struct UseDefaultConnector(());
impl Default for Config<UseDefaultConnector, http::Body> { impl Default for Config<UseDefaultConnector, proto::Body> {
fn default() -> Config<UseDefaultConnector, http::Body> { fn default() -> Config<UseDefaultConnector, proto::Body> {
Config { Config {
_body_type: PhantomData::<http::Body>, _body_type: PhantomData::<proto::Body>,
//connect_timeout: Duration::from_secs(10), //connect_timeout: Duration::from_secs(10),
connector: UseDefaultConnector(()), connector: UseDefaultConnector(()),
keep_alive: true, keep_alive: true,

View File

@@ -9,7 +9,7 @@ use std::time::{Duration, Instant};
use futures::{Future, Async, Poll}; use futures::{Future, Async, Poll};
use relay; use relay;
use http::{KeepAlive, KA}; use proto::{KeepAlive, KA};
pub struct Pool<T> { pub struct Pool<T> {
inner: Rc<RefCell<PoolInner<T>>>, inner: Rc<RefCell<PoolInner<T>>>,
@@ -337,7 +337,7 @@ mod tests {
use std::time::Duration; use std::time::Duration;
use futures::{Async, Future}; use futures::{Async, Future};
use futures::future; use futures::future;
use http::KeepAlive; use proto::KeepAlive;
use super::Pool; use super::Pool;
#[test] #[test]

View File

@@ -894,7 +894,7 @@ mod tests {
use header::Header; use header::Header;
use http::{ServerTransaction, Http1Transaction}; use proto::{ServerTransaction, Http1Transaction};
use bytes::BytesMut; use bytes::BytesMut;
use mime; use mime;

View File

@@ -45,15 +45,15 @@ pub use uri::Uri;
pub use client::Client; pub use client::Client;
pub use error::{Result, Error}; pub use error::{Result, Error};
pub use header::Headers; pub use header::Headers;
pub use http::{Body, Chunk}; pub use proto::{Body, Chunk};
pub use http::request::Request; pub use proto::request::Request;
pub use http::response::Response; pub use proto::response::Response;
pub use method::Method::{self, Get, Head, Post, Put, Delete}; pub use method::Method::{self, Get, Head, Post, Put, Delete};
pub use status::StatusCode::{self, Ok, BadRequest, NotFound}; pub use status::StatusCode::{self, Ok, BadRequest, NotFound};
pub use server::Server; pub use server::Server;
pub use version::HttpVersion; pub use version::HttpVersion;
#[cfg(feature = "raw_status")] #[cfg(feature = "raw_status")]
pub use http::RawStatus; pub use proto::RawStatus;
#[cfg(test)] #[cfg(test)]
mod mock; mod mock;
@@ -61,7 +61,7 @@ pub mod client;
pub mod error; pub mod error;
mod method; mod method;
pub mod header; pub mod header;
mod http; mod proto;
pub mod server; pub mod server;
mod status; mod status;
mod uri; mod uri;

View File

@@ -4,7 +4,7 @@ use futures::sync::mpsc;
use tokio_proto; use tokio_proto;
use std::borrow::Cow; use std::borrow::Cow;
use http::Chunk; use super::Chunk;
pub type TokioBody = tokio_proto::streaming::Body<Chunk, ::Error>; pub type TokioBody = tokio_proto::streaming::Body<Chunk, ::Error>;

View File

@@ -7,9 +7,9 @@ use futures::task::Task;
use tokio_io::{AsyncRead, AsyncWrite}; use tokio_io::{AsyncRead, AsyncWrite};
use tokio_proto::streaming::pipeline::{Frame, Transport}; use tokio_proto::streaming::pipeline::{Frame, Transport};
use http::{self, Http1Transaction}; use proto::{Http1Transaction};
use http::io::{Cursor, Buffered}; use super::io::{Cursor, Buffered};
use http::h1::{Encoder, Decoder}; use super::h1::{Encoder, Decoder};
use method::Method; use method::Method;
use version::HttpVersion; use version::HttpVersion;
@@ -51,7 +51,7 @@ where I: AsyncRead + AsyncWrite,
self.io.set_flush_pipeline(enabled); self.io.set_flush_pipeline(enabled);
} }
fn poll2(&mut self) -> Poll<Option<Frame<http::MessageHead<T::Incoming>, http::Chunk, ::Error>>, io::Error> { fn poll2(&mut self) -> Poll<Option<Frame<super::MessageHead<T::Incoming>, super::Chunk, ::Error>>, io::Error> {
trace!("Conn::poll()"); trace!("Conn::poll()");
loop { loop {
@@ -109,7 +109,7 @@ where I: AsyncRead + AsyncWrite,
} }
} }
fn read_head(&mut self) -> Poll<Option<Frame<http::MessageHead<T::Incoming>, http::Chunk, ::Error>>, io::Error> { fn read_head(&mut self) -> Poll<Option<Frame<super::MessageHead<T::Incoming>, super::Chunk, ::Error>>, io::Error> {
debug_assert!(self.can_read_head()); debug_assert!(self.can_read_head());
trace!("Conn::read_head"); trace!("Conn::read_head");
@@ -164,7 +164,7 @@ where I: AsyncRead + AsyncWrite,
} }
} }
fn read_body(&mut self) -> Poll<Option<http::Chunk>, io::Error> { fn read_body(&mut self) -> Poll<Option<super::Chunk>, io::Error> {
debug_assert!(self.can_read_body()); debug_assert!(self.can_read_body());
trace!("Conn::read_body"); trace!("Conn::read_body");
@@ -173,7 +173,7 @@ where I: AsyncRead + AsyncWrite,
Reading::Body(ref mut decoder) => { Reading::Body(ref mut decoder) => {
let slice = try_ready!(decoder.decode(&mut self.io)); let slice = try_ready!(decoder.decode(&mut self.io));
if !slice.is_empty() { 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() { } else if decoder.is_eof() {
(Reading::KeepAlive, Ok(Async::Ready(None))) (Reading::KeepAlive, Ok(Async::Ready(None)))
} else { } else {
@@ -277,7 +277,7 @@ where I: AsyncRead + AsyncWrite,
} }
} }
fn write_head(&mut self, head: http::MessageHead<T::Outgoing>, body: bool) { fn write_head(&mut self, head: super::MessageHead<T::Outgoing>, body: bool) {
debug_assert!(self.can_write_head()); debug_assert!(self.can_write_head());
let wants_keep_alive = head.should_keep_alive(); let wants_keep_alive = head.should_keep_alive();
@@ -418,7 +418,7 @@ where I: AsyncRead + AsyncWrite,
T: Http1Transaction, T: Http1Transaction,
K: KeepAlive, K: KeepAlive,
T::Outgoing: fmt::Debug { T::Outgoing: fmt::Debug {
type Item = Frame<http::MessageHead<T::Incoming>, http::Chunk, ::Error>; type Item = Frame<super::MessageHead<T::Incoming>, super::Chunk, ::Error>;
type Error = io::Error; type Error = io::Error;
#[inline] #[inline]
@@ -436,7 +436,7 @@ where I: AsyncRead + AsyncWrite,
T: Http1Transaction, T: Http1Transaction,
K: KeepAlive, K: KeepAlive,
T::Outgoing: fmt::Debug { T::Outgoing: fmt::Debug {
type SinkItem = Frame<http::MessageHead<T::Outgoing>, B, ::Error>; type SinkItem = Frame<super::MessageHead<T::Outgoing>, B, ::Error>;
type SinkError = io::Error; type SinkError = io::Error;
#[inline] #[inline]
@@ -692,7 +692,7 @@ impl<B, K: KeepAlive> State<B, K> {
// The DebugFrame and DebugChunk are simple Debug implementations that allow // The DebugFrame and DebugChunk are simple Debug implementations that allow
// us to dump the frame into logs, without logging the entirety of the bytes. // 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<http::MessageHead<T>, B, ::Error>); struct DebugFrame<'a, T: fmt::Debug + 'a, B: AsRef<[u8]> + 'a>(&'a Frame<super::MessageHead<T>, B, ::Error>);
impl<'a, T: fmt::Debug + 'a, B: AsRef<[u8]> + 'a> fmt::Debug for DebugFrame<'a, T, B> { 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 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -727,8 +727,8 @@ mod tests {
use futures::future; use futures::future;
use tokio_proto::streaming::pipeline::Frame; use tokio_proto::streaming::pipeline::Frame;
use http::{self, MessageHead, ServerTransaction}; use proto::{self, MessageHead, ServerTransaction};
use http::h1::Encoder; use super::super::h1::Encoder;
use mock::AsyncIo; use mock::AsyncIo;
use super::{Conn, Reading, Writing}; 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 good_message = b"GET / HTTP/1.1\r\n\r\n".to_vec();
let len = good_message.len(); let len = good_message.len();
let io = AsyncIo::new_buf(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() { match conn.poll().unwrap() {
Async::Ready(Some(Frame::Message { message, body: false })) => { Async::Ready(Some(Frame::Message { message, body: false })) => {
assert_eq!(message, MessageHead { assert_eq!(message, MessageHead {
subject: ::http::RequestLine(::Get, Uri::from_str("/").unwrap()), subject: ::proto::RequestLine(::Get, Uri::from_str("/").unwrap()),
.. MessageHead::default() .. MessageHead::default()
}) })
}, },
@@ -768,7 +768,7 @@ mod tests {
let _: Result<(), ()> = future::lazy(|| { let _: Result<(), ()> = future::lazy(|| {
let good_message = b"GET / HTTP/1.1\r\nHost: foo.bar\r\n\r\n".to_vec(); 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 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()); assert!(conn.poll().unwrap().is_not_ready());
conn.io.io_mut().block_in(50); conn.io.io_mut().block_in(50);
let async = conn.poll().unwrap(); let async = conn.poll().unwrap();
@@ -784,7 +784,7 @@ mod tests {
#[test] #[test]
fn test_conn_init_read_eof_idle() { fn test_conn_init_read_eof_idle() {
let io = AsyncIo::new_buf(vec![], 1); 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(); conn.state.idle();
match conn.poll().unwrap() { match conn.poll().unwrap() {
@@ -796,7 +796,7 @@ mod tests {
#[test] #[test]
fn test_conn_init_read_eof_idle_partial_parse() { fn test_conn_init_read_eof_idle_partial_parse() {
let io = AsyncIo::new_buf(b"GET / HTTP/1.1".to_vec(), 100); 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(); conn.state.idle();
match conn.poll().unwrap() { match conn.poll().unwrap() {
@@ -808,7 +808,7 @@ mod tests {
#[test] #[test]
fn test_conn_init_read_eof_busy() { fn test_conn_init_read_eof_busy() {
let io = AsyncIo::new_buf(vec![], 1); 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(); conn.state.busy();
match conn.poll().unwrap() { match conn.poll().unwrap() {
@@ -820,7 +820,7 @@ mod tests {
#[test] #[test]
fn test_conn_closed_read() { fn test_conn_closed_read() {
let io = AsyncIo::new_buf(vec![], 0); 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(); conn.state.close();
match conn.poll().unwrap() { match conn.poll().unwrap() {
@@ -835,8 +835,8 @@ mod tests {
let _ = pretty_env_logger::init(); let _ = pretty_env_logger::init();
let _: Result<(), ()> = future::lazy(|| { let _: Result<(), ()> = future::lazy(|| {
let io = AsyncIo::new_buf(vec![], 0); 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());
let max = ::http::io::MAX_BUFFER_SIZE + 4096; let max = ::proto::io::MAX_BUFFER_SIZE + 4096;
conn.state.writing = Writing::Body(Encoder::length((max * 2) as u64), None); 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()); 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() { fn test_conn_body_write_chunked() {
let _: Result<(), ()> = future::lazy(|| { let _: Result<(), ()> = future::lazy(|| {
let io = AsyncIo::new_buf(vec![], 4096); 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); conn.state.writing = Writing::Body(Encoder::chunked(), None);
assert!(conn.start_send(Frame::Body { chunk: Some("headers".into()) }).unwrap().is_ready()); assert!(conn.start_send(Frame::Body { chunk: Some("headers".into()) }).unwrap().is_ready());
@@ -876,7 +876,7 @@ mod tests {
fn test_conn_body_flush() { fn test_conn_body_flush() {
let _: Result<(), ()> = future::lazy(|| { let _: Result<(), ()> = future::lazy(|| {
let io = AsyncIo::new_buf(vec![], 1024 * 1024 * 5); 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); 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.start_send(Frame::Body { chunk: Some(vec![b'a'; 1024 * 1024].into()) }).unwrap().is_ready());
assert!(conn.state.writing.is_queued()); assert!(conn.state.writing.is_queued());
@@ -912,7 +912,7 @@ mod tests {
// test that once writing is done, unparks // test that once writing is done, unparks
let f = future::lazy(|| { let f = future::lazy(|| {
let io = AsyncIo::new_buf(vec![], 4096); 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; conn.state.reading = Reading::KeepAlive;
assert!(conn.poll().unwrap().is_not_ready()); assert!(conn.poll().unwrap().is_not_ready());
@@ -926,7 +926,7 @@ mod tests {
// test that flushing when not waiting on read doesn't unpark // test that flushing when not waiting on read doesn't unpark
let f = future::lazy(|| { let f = future::lazy(|| {
let io = AsyncIo::new_buf(vec![], 4096); 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; conn.state.writing = Writing::KeepAlive;
assert!(conn.poll_complete().unwrap().is_ready()); assert!(conn.poll_complete().unwrap().is_ready());
Ok::<(), ()>(()) Ok::<(), ()>(())
@@ -937,7 +937,7 @@ mod tests {
// test that flushing and writing isn't done doesn't unpark // test that flushing and writing isn't done doesn't unpark
let f = future::lazy(|| { let f = future::lazy(|| {
let io = AsyncIo::new_buf(vec![], 4096); 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; conn.state.reading = Reading::KeepAlive;
assert!(conn.poll().unwrap().is_not_ready()); assert!(conn.poll().unwrap().is_not_ready());
conn.state.writing = Writing::Body(Encoder::length(5_000), None); conn.state.writing = Writing::Body(Encoder::length(5_000), None);
@@ -950,7 +950,7 @@ mod tests {
#[test] #[test]
fn test_conn_closed_write() { fn test_conn_closed_write() {
let io = AsyncIo::new_buf(vec![], 0); 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(); conn.state.close();
match conn.start_send(Frame::Body { chunk: Some(b"foobar".to_vec().into()) }) { match conn.start_send(Frame::Body { chunk: Some(b"foobar".to_vec().into()) }) {
@@ -964,7 +964,7 @@ mod tests {
#[test] #[test]
fn test_conn_write_empty_chunk() { fn test_conn_write_empty_chunk() {
let io = AsyncIo::new_buf(vec![], 0); 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; conn.state.writing = Writing::KeepAlive;
assert!(conn.start_send(Frame::Body { chunk: None }).unwrap().is_ready()); assert!(conn.start_send(Frame::Body { chunk: None }).unwrap().is_ready());

View File

@@ -3,7 +3,7 @@ use std::io;
use futures::{Async, Poll}; use futures::{Async, Poll};
use bytes::Bytes; use bytes::Bytes;
use http::io::MemRead; use proto::io::MemRead;
use self::Kind::{Length, Chunked, Eof}; use self::Kind::{Length, Chunked, Eof};
@@ -281,7 +281,7 @@ mod tests {
use std::io::Write; use std::io::Write;
use super::Decoder; use super::Decoder;
use super::ChunkedState; use super::ChunkedState;
use http::io::MemRead; use proto::io::MemRead;
use futures::{Async, Poll}; use futures::{Async, Poll};
use bytes::{BytesMut, Bytes}; use bytes::{BytesMut, Bytes};
use mock::AsyncIo; use mock::AsyncIo;

View File

@@ -1,7 +1,7 @@
use std::cmp; use std::cmp;
use std::io::{self, Write}; use std::io::{self, Write};
use http::io::AtomicWrite; use proto::io::AtomicWrite;
/// Encoders to handle different Transfer-Encodings. /// Encoders to handle different Transfer-Encodings.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]

View File

@@ -5,9 +5,9 @@ use httparse;
use bytes::{BytesMut, Bytes}; use bytes::{BytesMut, Bytes};
use header::{self, Headers, ContentLength, TransferEncoding}; use header::{self, Headers, ContentLength, TransferEncoding};
use http::{MessageHead, RawStatus, Http1Transaction, ParseResult, use proto::{MessageHead, RawStatus, Http1Transaction, ParseResult,
ServerTransaction, ClientTransaction, RequestLine, RequestHead}; ServerTransaction, ClientTransaction, RequestLine, RequestHead};
use http::h1::{Encoder, Decoder, date}; use proto::h1::{Encoder, Decoder, date};
use method::Method; use method::Method;
use status::StatusCode; use status::StatusCode;
use version::HttpVersion::{Http10, Http11}; use version::HttpVersion::{Http10, Http11};
@@ -381,7 +381,7 @@ fn extend(dst: &mut Vec<u8>, data: &[u8]) {
mod tests { mod tests {
use bytes::BytesMut; use bytes::BytesMut;
use http::{MessageHead, ServerTransaction, ClientTransaction, Http1Transaction}; use proto::{MessageHead, ServerTransaction, ClientTransaction, Http1Transaction};
use header::{ContentLength, TransferEncoding}; use header::{ContentLength, TransferEncoding};
#[test] #[test]
@@ -438,7 +438,7 @@ mod tests {
use super::Decoder; use super::Decoder;
let method = &mut None; let method = &mut None;
let mut head = MessageHead::<::http::RequestLine>::default(); let mut head = MessageHead::<::proto::RequestLine>::default();
head.subject.0 = ::Method::Get; head.subject.0 = ::Method::Get;
assert_eq!(Decoder::length(0), ServerTransaction::decoder(&head, method).unwrap()); assert_eq!(Decoder::length(0), ServerTransaction::decoder(&head, method).unwrap());
@@ -474,7 +474,7 @@ mod tests {
use super::Decoder; use super::Decoder;
let method = &mut Some(::Method::Get); let method = &mut Some(::Method::Get);
let mut head = MessageHead::<::http::RawStatus>::default(); let mut head = MessageHead::<::proto::RawStatus>::default();
head.subject.0 = 204; head.subject.0 = 204;
assert_eq!(Decoder::length(0), ClientTransaction::decoder(&head, method).unwrap()); assert_eq!(Decoder::length(0), ClientTransaction::decoder(&head, method).unwrap());

View File

@@ -6,7 +6,7 @@ use std::ptr;
use futures::{Async, Poll}; use futures::{Async, Poll};
use tokio_io::{AsyncRead, AsyncWrite}; use tokio_io::{AsyncRead, AsyncWrite};
use http::{Http1Transaction, MessageHead}; use super::{Http1Transaction, MessageHead};
use bytes::{BytesMut, Bytes}; use bytes::{BytesMut, Bytes};
const INIT_BUFFER_SIZE: usize = 8192; const INIT_BUFFER_SIZE: usize = 8192;

View File

@@ -7,7 +7,7 @@ use std::net::SocketAddr;
use http_types; use http_types;
use header::Headers; use header::Headers;
use http::{Body, MessageHead, RequestHead, RequestLine}; use proto::{Body, MessageHead, RequestHead, RequestLine};
use method::Method; use method::Method;
use uri::{self, Uri}; use uri::{self, Uri};
use version::HttpVersion; use version::HttpVersion;
@@ -189,7 +189,7 @@ pub fn split<B>(req: Request<B>) -> (RequestHead, Option<B>) {
uri::origin_form(&req.uri) uri::origin_form(&req.uri)
}; };
let head = RequestHead { let head = RequestHead {
subject: ::http::RequestLine(req.method, uri), subject: ::proto::RequestLine(req.method, uri),
headers: req.headers, headers: req.headers,
version: req.version, version: req.version,
}; };

View File

@@ -6,7 +6,7 @@ use std::mem::replace;
use http_types; use http_types;
use header::{Header, Headers}; use header::{Header, Headers};
use http::{MessageHead, ResponseHead, Body}; use proto::{MessageHead, ResponseHead, Body};
use status::StatusCode; use status::StatusCode;
use version::HttpVersion; use version::HttpVersion;
@@ -16,7 +16,7 @@ pub struct Response<B = Body> {
headers: Headers, headers: Headers,
status: StatusCode, status: StatusCode,
#[cfg(feature = "raw_status")] #[cfg(feature = "raw_status")]
raw_status: ::http::RawStatus, raw_status: ::proto::RawStatus,
body: Option<B>, body: Option<B>,
} }
@@ -49,7 +49,7 @@ impl<B> Response<B> {
/// a received response. /// a received response.
#[inline] #[inline]
#[cfg(feature = "raw_status")] #[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. /// Set the `StatusCode` for this response.
#[inline] #[inline]

View File

@@ -5,9 +5,9 @@ use http_types;
use tokio_service::{NewService, Service}; use tokio_service::{NewService, Service};
use error::Error; use error::Error;
use http::Body; use proto::Body;
use http::request::Request; use proto::request::Request;
use http::response::Response; use proto::response::Response;
/// Wraps a `Future` returning an `http::Response` into /// Wraps a `Future` returning an `http::Response` into
/// a `Future` returning a `hyper::server::Response`. /// a `Future` returning a `hyper::server::Response`.

View File

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