diff --git a/.gitignore b/.gitignore index 4fffb2f89c..2cfdcba8c7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ /target /Cargo.lock +/hypernet/target +/hypernet/Cargo.lock +/hyperprotocol/target +/hyperprotocol/Cargo.lock diff --git a/.travis.yml b/.travis.yml index 99e1214b35..eed799feeb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,7 @@ cache: directories: - target -script: - - cargo build - - cargo test - - cargo bench +script: ./script.sh after_success: | [ $TRAVIS_BRANCH = master ] && diff --git a/Cargo.toml b/Cargo.toml index 37847ebdc7..1a5796dcee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,17 +12,21 @@ authors = ["Sean McArthur ", keywords = ["http", "hyper", "hyperium"] [dependencies] -cookie = "*" httparse = "*" log = ">= 0.2.0" -mime = "*" -num_cpus = "*" -openssl = "*" -rustc-serialize = "*" time = "*" -unicase = "*" +num_cpus = "*" url = "*" +[dependencies.hypernet] +path = "hypernet" + +[dependencies.hyperprotocol] +path = "hyperprotocol" + [dev-dependencies] env_logger = "*" +[dev-dependencies.hypernet] +path = "hypernet" +features = ["mock"] diff --git a/benches/client.rs b/benches/client.rs index ab9527994f..82b404bb4b 100644 --- a/benches/client.rs +++ b/benches/client.rs @@ -101,4 +101,3 @@ fn bench_mock_hyper(b: &mut test::Bencher) { .read_to_string(&mut s).unwrap() }); } - diff --git a/benches/server.rs b/benches/server.rs new file mode 100644 index 0000000000..50e339efbd --- /dev/null +++ b/benches/server.rs @@ -0,0 +1,34 @@ +#![deny(warnings)] +#![feature(test)] +extern crate hyper; +extern crate test; + +use test::Bencher; +use std::io::{Read, Write}; + +use hyper::method::Method::Get; +use hyper::server::{Request, Response}; + +static PHRASE: &'static [u8] = b"Benchmarking hyper vs others!"; + +fn request(url: hyper::Url) { + let req = hyper::client::Request::new(Get, url).unwrap(); + let mut s = String::new(); + req.start().unwrap().send().unwrap().read_to_string(&mut s).unwrap(); +} + +fn hyper_handle(_: Request, res: Response) { + let mut res = res.start().unwrap(); + res.write_all(PHRASE).unwrap(); + res.end().unwrap(); +} + +#[bench] +fn bench_hyper(b: &mut Bencher) { + let server = hyper::Server::http(hyper_handle); + let mut listener = server.listen("127.0.0.1").unwrap(); + + let url = hyper::Url::parse(&*format!("http://{}", listener.socket)).unwrap(); + b.iter(|| request(url.clone())); + listener.close().unwrap(); +} diff --git a/hypernet/Cargo.toml b/hypernet/Cargo.toml new file mode 100644 index 0000000000..919dc8424d --- /dev/null +++ b/hypernet/Cargo.toml @@ -0,0 +1,13 @@ +[package] + +name = "hypernet" +version = "0.0.1" +authors = ["Sean McArthur ", + "Jonathan Reem "] + +[dependencies] +log = ">= 0.2.0" +openssl = "*" + +[features] +mock = [] diff --git a/src/net.rs b/hypernet/src/lib.rs similarity index 97% rename from src/net.rs rename to hypernet/src/lib.rs index 1157514cc9..71305ffdc2 100644 --- a/src/net.rs +++ b/hypernet/src/lib.rs @@ -1,4 +1,13 @@ +#![feature(core, io)] +#![deny(missing_docs)] +#![cfg_attr(test, deny(warnings))] +#![cfg_attr(test, feature(box_syntax))] //! A collection of traits abstracting over Listeners and Streams. + +#[macro_use] +extern crate log; +extern crate openssl; + use std::any::{Any, TypeId}; use std::fmt; use std::io::{self, Read, Write}; @@ -347,9 +356,12 @@ fn lift_ssl_error(ssl: SslError) -> io::Error { } } +#[cfg(any(test, feature="mock"))] +pub mod mock; + #[cfg(test)] mod tests { - use mock::MockStream; + use super::mock::MockStream; use super::NetworkStream; #[test] diff --git a/src/mock.rs b/hypernet/src/mock.rs similarity index 79% rename from src/mock.rs rename to hypernet/src/mock.rs index cdf9e48d20..247a3390bd 100644 --- a/src/mock.rs +++ b/hypernet/src/mock.rs @@ -1,11 +1,15 @@ +//! Contains various utility types and macros useful for testing hyper clients. use std::fmt; use std::io::{self, Read, Write, Cursor}; use std::net::SocketAddr; -use net::{NetworkStream, NetworkConnector}; +use super::{NetworkStream, NetworkConnector}; +/// A `NetworkStream` compatible stream that writes into memory, and reads from memory. pub struct MockStream { + /// Data readable from stream. pub read: Cursor>, + /// Data written to the stream. pub write: Vec, } @@ -31,6 +35,7 @@ impl PartialEq for MockStream { } impl MockStream { + /// Creates a new empty mock stream. pub fn new() -> MockStream { MockStream { read: Cursor::new(vec![]), @@ -38,6 +43,7 @@ impl MockStream { } } + /// Creates a new stream with data that can be read from the stream. pub fn with_input(input: &[u8]) -> MockStream { MockStream { read: Cursor::new(input.to_vec()), @@ -68,6 +74,8 @@ impl NetworkStream for MockStream { } } +/// A `NetworkConnector` which creates `MockStream` instances exclusively. +/// It may be useful to intercept writes. pub struct MockConnector; impl NetworkConnector for MockConnector { @@ -78,7 +86,10 @@ impl NetworkConnector for MockConnector { } } -/// new connectors must be created if you wish to intercept requests. +/// This macro maps host URLs to a respective reply, which is given in plain-text. +/// It ignores, but stores, everything that is written to it. However, the stored +/// values are not accessible just yet. +#[macro_export] macro_rules! mock_connector ( ($name:ident { $($url:expr => $res:expr)* @@ -111,4 +122,3 @@ macro_rules! mock_connector ( ) ); - diff --git a/hyperprotocol/Cargo.toml b/hyperprotocol/Cargo.toml new file mode 100644 index 0000000000..b1c610880f --- /dev/null +++ b/hyperprotocol/Cargo.toml @@ -0,0 +1,17 @@ +[package] + +name = "hyperprotocol" +version = "0.0.1" +authors = ["Sean McArthur ", + "Jonathan Reem ", + "Pyfisch "] + +[dependencies] +cookie = "*" +httparse = "*" +log = ">= 0.2.0" +mime = "*" +rustc-serialize = "*" +time = "*" +unicase = "*" +url = "*" diff --git a/src/error.rs b/hyperprotocol/src/error.rs similarity index 100% rename from src/error.rs rename to hyperprotocol/src/error.rs diff --git a/src/header/common/accept.rs b/hyperprotocol/src/header/common/accept.rs similarity index 85% rename from src/header/common/accept.rs rename to hyperprotocol/src/header/common/accept.rs index 14ed97b45d..d02c198379 100644 --- a/src/header/common/accept.rs +++ b/hyperprotocol/src/header/common/accept.rs @@ -11,12 +11,12 @@ use header::QualityItem; /// Example: /// /// ``` -/// # use hyper::header::Headers; -/// # use hyper::header::Accept; -/// # use hyper::header::qitem; -/// use hyper::mime::Mime; -/// use hyper::mime::TopLevel::Text; -/// use hyper::mime::SubLevel::{Html, Xml}; +/// # use hyperprotocol::header::Headers; +/// # use hyperprotocol::header::Accept; +/// # use hyperprotocol::header::qitem; +/// use hyperprotocol::mime::Mime; +/// use hyperprotocol::mime::TopLevel::Text; +/// use hyperprotocol::mime::SubLevel::{Html, Xml}; /// # let mut headers = Headers::new(); /// headers.set(Accept(vec![ /// qitem(Mime(Text, Html, vec![])), diff --git a/src/header/common/accept_charset.rs b/hyperprotocol/src/header/common/accept_charset.rs similarity index 100% rename from src/header/common/accept_charset.rs rename to hyperprotocol/src/header/common/accept_charset.rs diff --git a/src/header/common/accept_encoding.rs b/hyperprotocol/src/header/common/accept_encoding.rs similarity index 100% rename from src/header/common/accept_encoding.rs rename to hyperprotocol/src/header/common/accept_encoding.rs diff --git a/src/header/common/accept_language.rs b/hyperprotocol/src/header/common/accept_language.rs similarity index 100% rename from src/header/common/accept_language.rs rename to hyperprotocol/src/header/common/accept_language.rs diff --git a/src/header/common/access_control/allow_headers.rs b/hyperprotocol/src/header/common/access_control/allow_headers.rs similarity index 100% rename from src/header/common/access_control/allow_headers.rs rename to hyperprotocol/src/header/common/access_control/allow_headers.rs diff --git a/src/header/common/access_control/allow_methods.rs b/hyperprotocol/src/header/common/access_control/allow_methods.rs similarity index 100% rename from src/header/common/access_control/allow_methods.rs rename to hyperprotocol/src/header/common/access_control/allow_methods.rs diff --git a/src/header/common/access_control/allow_origin.rs b/hyperprotocol/src/header/common/access_control/allow_origin.rs similarity index 97% rename from src/header/common/access_control/allow_origin.rs rename to hyperprotocol/src/header/common/access_control/allow_origin.rs index b7bde04d0e..519ff84f87 100644 --- a/src/header/common/access_control/allow_origin.rs +++ b/hyperprotocol/src/header/common/access_control/allow_origin.rs @@ -1,8 +1,8 @@ -extern crate url; - -use std::fmt::{self}; +use std::fmt; use std::str; +use url; + use header; /// The `Access-Control-Allow-Origin` response header, diff --git a/src/header/common/access_control/max_age.rs b/hyperprotocol/src/header/common/access_control/max_age.rs similarity index 100% rename from src/header/common/access_control/max_age.rs rename to hyperprotocol/src/header/common/access_control/max_age.rs diff --git a/src/header/common/access_control/mod.rs b/hyperprotocol/src/header/common/access_control/mod.rs similarity index 100% rename from src/header/common/access_control/mod.rs rename to hyperprotocol/src/header/common/access_control/mod.rs diff --git a/src/header/common/access_control/request_headers.rs b/hyperprotocol/src/header/common/access_control/request_headers.rs similarity index 100% rename from src/header/common/access_control/request_headers.rs rename to hyperprotocol/src/header/common/access_control/request_headers.rs diff --git a/src/header/common/access_control/request_method.rs b/hyperprotocol/src/header/common/access_control/request_method.rs similarity index 100% rename from src/header/common/access_control/request_method.rs rename to hyperprotocol/src/header/common/access_control/request_method.rs diff --git a/src/header/common/allow.rs b/hyperprotocol/src/header/common/allow.rs similarity index 100% rename from src/header/common/allow.rs rename to hyperprotocol/src/header/common/allow.rs diff --git a/src/header/common/authorization.rs b/hyperprotocol/src/header/common/authorization.rs similarity index 100% rename from src/header/common/authorization.rs rename to hyperprotocol/src/header/common/authorization.rs diff --git a/src/header/common/cache_control.rs b/hyperprotocol/src/header/common/cache_control.rs similarity index 100% rename from src/header/common/cache_control.rs rename to hyperprotocol/src/header/common/cache_control.rs diff --git a/src/header/common/connection.rs b/hyperprotocol/src/header/common/connection.rs similarity index 100% rename from src/header/common/connection.rs rename to hyperprotocol/src/header/common/connection.rs diff --git a/src/header/common/content_encoding.rs b/hyperprotocol/src/header/common/content_encoding.rs similarity index 100% rename from src/header/common/content_encoding.rs rename to hyperprotocol/src/header/common/content_encoding.rs diff --git a/src/header/common/content_length.rs b/hyperprotocol/src/header/common/content_length.rs similarity index 100% rename from src/header/common/content_length.rs rename to hyperprotocol/src/header/common/content_length.rs diff --git a/src/header/common/content_type.rs b/hyperprotocol/src/header/common/content_type.rs similarity index 100% rename from src/header/common/content_type.rs rename to hyperprotocol/src/header/common/content_type.rs diff --git a/src/header/common/cookie.rs b/hyperprotocol/src/header/common/cookie.rs similarity index 100% rename from src/header/common/cookie.rs rename to hyperprotocol/src/header/common/cookie.rs diff --git a/src/header/common/date.rs b/hyperprotocol/src/header/common/date.rs similarity index 100% rename from src/header/common/date.rs rename to hyperprotocol/src/header/common/date.rs diff --git a/src/header/common/etag.rs b/hyperprotocol/src/header/common/etag.rs similarity index 100% rename from src/header/common/etag.rs rename to hyperprotocol/src/header/common/etag.rs diff --git a/src/header/common/expect.rs b/hyperprotocol/src/header/common/expect.rs similarity index 100% rename from src/header/common/expect.rs rename to hyperprotocol/src/header/common/expect.rs diff --git a/src/header/common/expires.rs b/hyperprotocol/src/header/common/expires.rs similarity index 100% rename from src/header/common/expires.rs rename to hyperprotocol/src/header/common/expires.rs diff --git a/src/header/common/host.rs b/hyperprotocol/src/header/common/host.rs similarity index 100% rename from src/header/common/host.rs rename to hyperprotocol/src/header/common/host.rs diff --git a/src/header/common/if_match.rs b/hyperprotocol/src/header/common/if_match.rs similarity index 100% rename from src/header/common/if_match.rs rename to hyperprotocol/src/header/common/if_match.rs diff --git a/src/header/common/if_modified_since.rs b/hyperprotocol/src/header/common/if_modified_since.rs similarity index 100% rename from src/header/common/if_modified_since.rs rename to hyperprotocol/src/header/common/if_modified_since.rs diff --git a/src/header/common/if_none_match.rs b/hyperprotocol/src/header/common/if_none_match.rs similarity index 100% rename from src/header/common/if_none_match.rs rename to hyperprotocol/src/header/common/if_none_match.rs diff --git a/src/header/common/if_unmodified_since.rs b/hyperprotocol/src/header/common/if_unmodified_since.rs similarity index 100% rename from src/header/common/if_unmodified_since.rs rename to hyperprotocol/src/header/common/if_unmodified_since.rs diff --git a/src/header/common/last_modified.rs b/hyperprotocol/src/header/common/last_modified.rs similarity index 100% rename from src/header/common/last_modified.rs rename to hyperprotocol/src/header/common/last_modified.rs diff --git a/src/header/common/location.rs b/hyperprotocol/src/header/common/location.rs similarity index 100% rename from src/header/common/location.rs rename to hyperprotocol/src/header/common/location.rs diff --git a/src/header/common/mod.rs b/hyperprotocol/src/header/common/mod.rs similarity index 100% rename from src/header/common/mod.rs rename to hyperprotocol/src/header/common/mod.rs diff --git a/src/header/common/pragma.rs b/hyperprotocol/src/header/common/pragma.rs similarity index 100% rename from src/header/common/pragma.rs rename to hyperprotocol/src/header/common/pragma.rs diff --git a/src/header/common/referer.rs b/hyperprotocol/src/header/common/referer.rs similarity index 100% rename from src/header/common/referer.rs rename to hyperprotocol/src/header/common/referer.rs diff --git a/src/header/common/server.rs b/hyperprotocol/src/header/common/server.rs similarity index 100% rename from src/header/common/server.rs rename to hyperprotocol/src/header/common/server.rs diff --git a/src/header/common/set_cookie.rs b/hyperprotocol/src/header/common/set_cookie.rs similarity index 100% rename from src/header/common/set_cookie.rs rename to hyperprotocol/src/header/common/set_cookie.rs diff --git a/src/header/common/transfer_encoding.rs b/hyperprotocol/src/header/common/transfer_encoding.rs similarity index 100% rename from src/header/common/transfer_encoding.rs rename to hyperprotocol/src/header/common/transfer_encoding.rs diff --git a/src/header/common/upgrade.rs b/hyperprotocol/src/header/common/upgrade.rs similarity index 100% rename from src/header/common/upgrade.rs rename to hyperprotocol/src/header/common/upgrade.rs diff --git a/src/header/common/user_agent.rs b/hyperprotocol/src/header/common/user_agent.rs similarity index 100% rename from src/header/common/user_agent.rs rename to hyperprotocol/src/header/common/user_agent.rs diff --git a/src/header/common/vary.rs b/hyperprotocol/src/header/common/vary.rs similarity index 100% rename from src/header/common/vary.rs rename to hyperprotocol/src/header/common/vary.rs diff --git a/src/header/internals/cell.rs b/hyperprotocol/src/header/internals/cell.rs similarity index 100% rename from src/header/internals/cell.rs rename to hyperprotocol/src/header/internals/cell.rs diff --git a/src/header/internals/item.rs b/hyperprotocol/src/header/internals/item.rs similarity index 100% rename from src/header/internals/item.rs rename to hyperprotocol/src/header/internals/item.rs diff --git a/src/header/internals/mod.rs b/hyperprotocol/src/header/internals/mod.rs similarity index 100% rename from src/header/internals/mod.rs rename to hyperprotocol/src/header/internals/mod.rs diff --git a/src/header/mod.rs b/hyperprotocol/src/header/mod.rs similarity index 99% rename from src/header/mod.rs rename to hyperprotocol/src/header/mod.rs index 49a25dd86e..e5537cc222 100644 --- a/src/header/mod.rs +++ b/hyperprotocol/src/header/mod.rs @@ -147,7 +147,7 @@ impl Headers { /// Example: /// /// ``` - /// # use hyper::header::Headers; + /// # use hyperprotocol::header::Headers; /// # let mut headers = Headers::new(); /// let raw_content_type = headers.get_raw("content-type"); /// ``` @@ -162,7 +162,7 @@ impl Headers { /// Example: /// /// ``` - /// # use hyper::header::Headers; + /// # use hyperprotocol::header::Headers; /// # let mut headers = Headers::new(); /// headers.set_raw("content-length", vec![b"5".to_vec()]); /// ``` @@ -190,8 +190,8 @@ impl Headers { /// Example: /// /// ``` - /// # use hyper::header::Headers; - /// # use hyper::header::ContentType; + /// # use hyperprotocol::header::Headers; + /// # use hyperprotocol::header::ContentType; /// # let mut headers = Headers::new(); /// let has_type = headers.has::(); /// ``` diff --git a/src/header/parsing.rs b/hyperprotocol/src/header/parsing.rs similarity index 100% rename from src/header/parsing.rs rename to hyperprotocol/src/header/parsing.rs diff --git a/src/header/shared/charset.rs b/hyperprotocol/src/header/shared/charset.rs similarity index 100% rename from src/header/shared/charset.rs rename to hyperprotocol/src/header/shared/charset.rs diff --git a/src/header/shared/encoding.rs b/hyperprotocol/src/header/shared/encoding.rs similarity index 100% rename from src/header/shared/encoding.rs rename to hyperprotocol/src/header/shared/encoding.rs diff --git a/src/header/shared/entity.rs b/hyperprotocol/src/header/shared/entity.rs similarity index 100% rename from src/header/shared/entity.rs rename to hyperprotocol/src/header/shared/entity.rs diff --git a/src/header/shared/mod.rs b/hyperprotocol/src/header/shared/mod.rs similarity index 100% rename from src/header/shared/mod.rs rename to hyperprotocol/src/header/shared/mod.rs diff --git a/src/header/shared/quality_item.rs b/hyperprotocol/src/header/shared/quality_item.rs similarity index 100% rename from src/header/shared/quality_item.rs rename to hyperprotocol/src/header/shared/quality_item.rs diff --git a/hyperprotocol/src/lib.rs b/hyperprotocol/src/lib.rs new file mode 100644 index 0000000000..592a0942d1 --- /dev/null +++ b/hyperprotocol/src/lib.rs @@ -0,0 +1,29 @@ +#![feature(core, box_syntax, unsafe_destructor, into_cow, convert)] +#![cfg_attr(test, feature(test))] +#![deny(missing_docs)] +#![cfg_attr(test, deny(warnings))] + +//! # Hyperprotocol +//! Hyperprotol contains the high-level semantics of HTTP. The provided code is used by both client +//! and server. + +extern crate cookie; +extern crate httparse; +#[macro_use] +extern crate log; +extern crate mime as mime_crate; +extern crate rustc_serialize as serialize; +extern crate time; +extern crate unicase; +extern crate url; + +#[cfg(test)] +extern crate test; + +pub use mime_crate as mime; + +pub mod error; +pub mod header; +pub mod method; +pub mod status; +pub mod version; diff --git a/src/method.rs b/hyperprotocol/src/method.rs similarity index 100% rename from src/method.rs rename to hyperprotocol/src/method.rs diff --git a/src/status.rs b/hyperprotocol/src/status.rs similarity index 98% rename from src/status.rs rename to hyperprotocol/src/status.rs index d91a0502b6..b3ab640c37 100644 --- a/src/status.rs +++ b/hyperprotocol/src/status.rs @@ -22,7 +22,7 @@ use std::cmp::Ordering; /// ```rust /// #![feature(core)] /// # use std::num::FromPrimitive; -/// # use hyper::status::StatusCode; +/// # use hyperprotocol::status::StatusCode; /// let statusopt: Option = FromPrimitive::from_u16(137u16); /// assert_eq!(statusopt.unwrap().class().default_code(), StatusCode::Continue); /// ``` @@ -357,7 +357,7 @@ impl Copy for StatusCode {} /// Formats the status code, *including* the canonical reason. /// /// ```rust -/// # use hyper::status::StatusCode::{ImATeapot, Unregistered}; +/// # use hyperprotocol::status::StatusCode::{ImATeapot, Unregistered}; /// assert_eq!(format!("{}", ImATeapot), "418 I'm a teapot"); /// assert_eq!(format!("{}", Unregistered(123)), /// "123 "); @@ -367,8 +367,8 @@ impl Copy for StatusCode {} /// /// ```rust /// #![feature(core)] +/// # use hyperprotocol::status::StatusCode::{ImATeapot, Unregistered}; /// # use std::num::ToPrimitive; -/// # use hyper::status::StatusCode::{ImATeapot, Unregistered}; /// assert_eq!(format!("{}", ImATeapot.to_u16().unwrap()), "418"); /// assert_eq!(format!("{}", Unregistered(123).to_u16().unwrap()), "123"); /// ``` @@ -696,8 +696,8 @@ impl StatusClass { /// example, this will produce `BadRequest` (400): /// /// ```rust - /// # use hyper::status::StatusClass::ClientError; - /// # use hyper::status::StatusCode::BadRequest; + /// # use hyperprotocol::status::StatusClass::ClientError; + /// # use hyperprotocol::status::StatusCode::BadRequest; /// assert_eq!(ClientError.default_code(), BadRequest); /// ``` /// @@ -721,7 +721,7 @@ impl StatusClass { /// This is demonstrated thusly: /// /// ```rust - /// # use hyper::status::StatusCode::{Unregistered, BadRequest}; + /// # use hyperprotocol::status::StatusCode::{Unregistered, BadRequest}; /// // Suppose we have received this status code. /// // You will never directly create an unregistered status code. /// let status = Unregistered(471); diff --git a/src/version.rs b/hyperprotocol/src/version.rs similarity index 100% rename from src/version.rs rename to hyperprotocol/src/version.rs diff --git a/script.sh b/script.sh new file mode 100755 index 0000000000..8101948f30 --- /dev/null +++ b/script.sh @@ -0,0 +1,11 @@ +cargo build +cargo test +cargo bench + +cd hypernet +cargo test +cargo bench + +cd ../hyperprotocol +cargo test +cargo bench diff --git a/src/lib.rs b/src/lib.rs index 86aa445fa2..2bd1c89707 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,8 @@ #![doc(html_root_url = "https://hyperium.github.io/hyper/hyper/index.html")] -#![feature(core, io, unsafe_destructor, into_cow, convert)] +#![feature(core, io, unsafe_destructor, into_cow)] #![deny(missing_docs)] #![cfg_attr(test, deny(warnings))] -#![cfg_attr(test, feature(alloc, test))] +#![cfg_attr(test, feature(alloc, test, convert))] //! # Hyper //! Hyper is a fast, modern HTTP implementation written in and for Rust. It @@ -126,29 +126,29 @@ //! implement `Reader` and can be read to get the data out of a `Response`. //! -extern crate rustc_serialize as serialize; extern crate time; extern crate url; -extern crate openssl; -extern crate cookie; -extern crate unicase; extern crate httparse; extern crate num_cpus; +#[macro_use] +extern crate hypernet; +extern crate hyperprotocol; #[macro_use] extern crate log; - #[cfg(test)] extern crate test; - -pub use mimewrapper::mime; pub use url::Url; pub use client::Client; -pub use error::{HttpResult, HttpError}; -pub use method::Method::{Get, Head, Post, Delete}; -pub use status::StatusCode::{Ok, BadRequest, NotFound}; pub use server::Server; +pub use hypernet as net; +#[cfg(test)] +pub use hypernet::mock as mock; +pub use hyperprotocol::{header, method, mime, status, version}; +pub use hyperprotocol::error::{self, HttpResult, HttpError}; +pub use hyperprotocol::method::Method::{Get, Head, Post, Delete}; +pub use hyperprotocol::status::StatusCode::{Ok, BadRequest, NotFound}; macro_rules! todo( ($($arg:tt)*) => (if cfg!(not(ndebug)) { @@ -164,26 +164,10 @@ macro_rules! inspect( }) ); -#[cfg(test)] -#[macro_use] -mod mock; - pub mod client; -pub mod error; -pub mod method; -pub mod header; pub mod http; -pub mod net; pub mod server; -pub mod status; pub mod uri; -pub mod version; - - -mod mimewrapper { - /// Re-exporting the mime crate, for convenience. - extern crate mime; -} #[allow(unconditional_recursion)] fn _assert_send() {