refactor(lib): rename internal http module to proto
This commit is contained in:
@@ -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<C, B = http::Body> {
|
||||
pub struct Client<C, B = proto::Body> {
|
||||
connector: C,
|
||||
handle: Handle,
|
||||
pool: Pool<TokioClient<B>>,
|
||||
}
|
||||
|
||||
impl Client<HttpConnector, http::Body> {
|
||||
impl Client<HttpConnector, proto::Body> {
|
||||
/// Create a new Client with the default config.
|
||||
#[inline]
|
||||
pub fn new(handle: &Handle) -> Client<HttpConnector, http::Body> {
|
||||
pub fn new(handle: &Handle) -> Client<HttpConnector, proto::Body> {
|
||||
Config::default().build(handle)
|
||||
}
|
||||
}
|
||||
|
||||
impl Client<HttpConnector, http::Body> {
|
||||
impl Client<HttpConnector, proto::Body> {
|
||||
/// Configure a Client.
|
||||
///
|
||||
/// # Example
|
||||
@@ -75,7 +75,7 @@ impl Client<HttpConnector, http::Body> {
|
||||
/// # }
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn configure() -> Config<UseDefaultConnector, http::Body> {
|
||||
pub fn configure() -> Config<UseDefaultConnector, proto::Body> {
|
||||
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> {
|
||||
client_rx: RefCell<Option<oneshot::Receiver<Pooled<TokioClient<B>>>>>,
|
||||
@@ -260,12 +260,12 @@ where T: AsyncRead + AsyncWrite + 'static,
|
||||
B: Stream<Error=::Error> + '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<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>;
|
||||
|
||||
fn bind_transport(&self, io: T) -> Self::BindTransport {
|
||||
@@ -286,13 +286,13 @@ where T: AsyncRead + AsyncWrite + 'static,
|
||||
B: Stream<Error=::Error>,
|
||||
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;
|
||||
|
||||
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
||||
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<C, B> {
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct UseDefaultConnector(());
|
||||
|
||||
impl Default for Config<UseDefaultConnector, http::Body> {
|
||||
fn default() -> Config<UseDefaultConnector, http::Body> {
|
||||
impl Default for Config<UseDefaultConnector, proto::Body> {
|
||||
fn default() -> Config<UseDefaultConnector, proto::Body> {
|
||||
Config {
|
||||
_body_type: PhantomData::<http::Body>,
|
||||
_body_type: PhantomData::<proto::Body>,
|
||||
//connect_timeout: Duration::from_secs(10),
|
||||
connector: UseDefaultConnector(()),
|
||||
keep_alive: true,
|
||||
|
||||
@@ -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<T> {
|
||||
inner: Rc<RefCell<PoolInner<T>>>,
|
||||
@@ -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]
|
||||
|
||||
@@ -894,7 +894,7 @@ mod tests {
|
||||
|
||||
use header::Header;
|
||||
|
||||
use http::{ServerTransaction, Http1Transaction};
|
||||
use proto::{ServerTransaction, Http1Transaction};
|
||||
use bytes::BytesMut;
|
||||
|
||||
use mime;
|
||||
|
||||
10
src/lib.rs
10
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;
|
||||
|
||||
@@ -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<Chunk, ::Error>;
|
||||
|
||||
@@ -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<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()");
|
||||
|
||||
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());
|
||||
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());
|
||||
|
||||
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<T::Outgoing>, body: bool) {
|
||||
fn write_head(&mut self, head: super::MessageHead<T::Outgoing>, 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::MessageHead<T::Incoming>, http::Chunk, ::Error>;
|
||||
type Item = Frame<super::MessageHead<T::Incoming>, 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<http::MessageHead<T::Outgoing>, B, ::Error>;
|
||||
type SinkItem = Frame<super::MessageHead<T::Outgoing>, B, ::Error>;
|
||||
type SinkError = io::Error;
|
||||
|
||||
#[inline]
|
||||
@@ -692,7 +692,7 @@ impl<B, K: KeepAlive> State<B, K> {
|
||||
|
||||
// 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<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> {
|
||||
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());
|
||||
@@ -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;
|
||||
@@ -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)]
|
||||
@@ -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<u8>, 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());
|
||||
@@ -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;
|
||||
@@ -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<B>(req: Request<B>) -> (RequestHead, Option<B>) {
|
||||
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,
|
||||
};
|
||||
@@ -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<B = Body> {
|
||||
headers: Headers,
|
||||
status: StatusCode,
|
||||
#[cfg(feature = "raw_status")]
|
||||
raw_status: ::http::RawStatus,
|
||||
raw_status: ::proto::RawStatus,
|
||||
body: Option<B>,
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ impl<B> Response<B> {
|
||||
/// 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]
|
||||
@@ -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`.
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user