diff --git a/Cargo.toml b/Cargo.toml index 2fab90cb..e1a2957e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,32 +1,25 @@ [package] name = "hyper" -version = "0.0.1" -authors = ["Sean McArthur "] +version = "0.0.14" +description = "A modern HTTP library." +readme = "README.md" +documentation = "http://hyperium.github.io/hyper/hyper/index.html" +repository = "https://github.com/hyperium/hyper" +license = "MIT" +authors = ["Sean McArthur ", + "Jonathan Reem "] -[dependencies.url] -git = "https://github.com/servo/rust-url" +[dependencies] +url = "*" +openssl = "*" +mime = "*" +unsafe-any = "*" +typeable = "*" +cookie = "*" +time = "*" +mucell = "*" -[dependencies.openssl] -git = "https://github.com/sfackler/rust-openssl" +[dev-dependencies] +curl = "*" -[dependencies.mime] -git = "https://github.com/hyperium/mime.rs" - -[dependencies.unsafe-any] -git = "https://github.com/reem/rust-unsafe-any" - -[dev-dependencies.curl] -git = "https://github.com/carllerche/curl-rust" - -[dev-dependencies.http] -git = "https://github.com/chris-morgan/rust-http" - -[dependencies.cookie] -git = "https://github.com/alexcrichton/cookie-rs" - -[dependencies.time] -git = "https://github.com/rust-lang/time" - -[dependencies.mucell] -git = "https://github.com/chris-morgan/mucell" diff --git a/README.md b/README.md index fef3a77c..87a62fee 100644 --- a/README.md +++ b/README.md @@ -59,42 +59,6 @@ fn main() { } ``` -## Scientific\* Benchmarks - -[Client Bench:](./benches/client.rs) - -``` -running 3 tests -test bench_curl ... bench: 400253 ns/iter (+/- 143539) -test bench_hyper ... bench: 181703 ns/iter (+/- 46529) - -test result: ok. 0 passed; 0 failed; 0 ignored; 2 measured -``` - -[Mock Client Bench:](./benches/client_mock_tcp.rs) - -``` -running 3 tests -test bench_mock_curl ... bench: 53987 ns/iter (+/- 1735) -test bench_mock_http ... bench: 43569 ns/iter (+/- 1409) -test bench_mock_hyper ... bench: 20996 ns/iter (+/- 1742) - -test result: ok. 0 passed; 0 failed; 0 ignored; 3 measured -``` - - -[Server Bench:](./benches/server.rs) - -``` -running 2 tests -test bench_http ... bench: 296539 ns/iter (+/- 58861) -test bench_hyper ... bench: 233069 ns/iter (+/- 90194) - -test result: ok. 0 passed; 0 failed; 0 ignored; 2 measured -``` - -\* No science was harmed in the making of this benchmark. - ## License [MIT](./LICENSE) diff --git a/benches/client.rs b/benches/client.rs index f6e9ef04..6bcee6fb 100644 --- a/benches/client.rs +++ b/benches/client.rs @@ -1,6 +1,5 @@ #![feature(macro_rules)] extern crate curl; -extern crate http; extern crate hyper; extern crate test; @@ -8,10 +7,8 @@ extern crate test; use std::fmt::{mod, Show}; use std::io::net::ip::Ipv4Addr; use hyper::server::{Request, Response, Server}; -use hyper::method::Method::Get; use hyper::header::Headers; use hyper::Client; -use hyper::client::RequestBuilder; fn listen() -> hyper::server::Listening { let server = Server::http(Ipv4Addr(127, 0, 0, 1), 0); @@ -24,16 +21,16 @@ macro_rules! try_return( Ok(v) => v, Err(..) => return } - }}) + }} +); fn handle(_r: Request, res: Response) { static BODY: &'static [u8] = b"Benchmarking hyper vs others!"; let mut res = try_return!(res.start()); - try_return!(res.write(BODY)) + try_return!(res.write(BODY)); try_return!(res.end()); } - #[bench] fn bench_curl(b: &mut test::Bencher) { let mut listening = listen(); @@ -81,26 +78,3 @@ fn bench_hyper(b: &mut test::Bencher) { listening.close().unwrap() } -/* -doesn't handle keep-alive properly... -#[bench] -fn bench_http(b: &mut test::Bencher) { - let mut listening = listen(); - let s = format!("http://{}/", listening.socket); - let url = s.as_slice(); - b.iter(|| { - let mut req: http::client::RequestWriter = http::client::RequestWriter::new( - http::method::Get, - hyper::Url::parse(url).unwrap() - ).unwrap(); - req.headers.extensions.insert("x-foo".to_string(), "Bar".to_string()); - // cant unwrap because Err contains RequestWriter, which does not implement Show - let mut res = match req.read_response() { - Ok(res) => res, - Err((_, ioe)) => panic!("http response failed = {}", ioe) - }; - res.read_to_string().unwrap(); - }); - listening.close().unwrap() -} -*/ diff --git a/benches/client_mock_tcp.rs b/benches/client_mock_tcp.rs index 1321a568..2fd2ce19 100644 --- a/benches/client_mock_tcp.rs +++ b/benches/client_mock_tcp.rs @@ -1,6 +1,5 @@ #![feature(default_type_params)] extern crate curl; -extern crate http; extern crate hyper; extern crate test; @@ -8,12 +7,10 @@ extern crate test; use std::fmt::{mod, Show}; use std::str::from_str; use std::io::{IoResult, MemReader}; -use std::io::net::ip::{SocketAddr, ToSocketAddr}; +use std::io::net::ip::SocketAddr; use std::os; use std::path::BytesContainer; -use http::connecter::Connecter; - use hyper::net; static README: &'static [u8] = include_bin!("../README.md"); @@ -117,27 +114,3 @@ fn bench_mock_hyper(b: &mut test::Bencher) { }); } -impl Connecter for MockStream { - fn connect(_addr: SocketAddr, _host: &str, _use_ssl: bool) -> IoResult { - Ok(MockStream::new()) - } -} - -#[bench] -fn bench_mock_http(b: &mut test::Bencher) { - let url = "http://127.0.0.1:1337/"; - b.iter(|| { - let mut req: http::client::RequestWriter = http::client::RequestWriter::new( - http::method::Get, - hyper::Url::parse(url).unwrap() - ).unwrap(); - req.headers.extensions.insert("x-foo".to_string(), "Bar".to_string()); - // cant unwrap because Err contains RequestWriter, which does not implement Show - let mut res = match req.read_response() { - Ok(res) => res, - Err(..) => panic!("http response failed") - }; - res.read_to_string().unwrap(); - }); -} - diff --git a/benches/server.rs b/benches/server.rs index d18bf596..6d51fe6e 100644 --- a/benches/server.rs +++ b/benches/server.rs @@ -1,14 +1,9 @@ -// You have to ctrl-C after running this benchmark, since there is no way to kill -// a rust-http server. - -extern crate http; extern crate hyper; extern crate test; use test::Bencher; -use std::io::net::ip::{SocketAddr, Ipv4Addr}; +use std::io::net::ip::Ipv4Addr; -use http::server::Server; use hyper::method::Method::Get; use hyper::server::{Request, Response}; @@ -35,36 +30,3 @@ fn bench_hyper(b: &mut Bencher) { listener.close().unwrap(); } -static mut created_http: bool = false; - -#[deriving(Clone)] -struct HttpServer; - -impl Server for HttpServer { - fn get_config(&self) -> http::server::Config { - http::server::Config { - bind_address: SocketAddr { - ip: Ipv4Addr(127, 0, 0, 1), - port: 4000 - } - } - } - - fn handle_request(&self, _: http::server::Request, res: &mut http::server::ResponseWriter) { - res.write(PHRASE).unwrap(); - } -} - -#[bench] -fn bench_http(b: &mut Bencher) { - if unsafe { !created_http } { - spawn(proc() { HttpServer.serve_forever() }); - unsafe { created_http = true } - // Mega hack because there is no way to wait for serve_forever to start: - std::io::timer::sleep(std::time::duration::Duration::seconds(1)); - } - - let url = hyper::Url::parse("http://localhost:4000").unwrap(); - b.iter(|| request(url.clone())); -} - diff --git a/examples/server.rs b/examples/server.rs index a4598793..128993b1 100644 --- a/examples/server.rs +++ b/examples/server.rs @@ -18,7 +18,7 @@ macro_rules! try_return( Err(e) => { error!("Error: {}", e); return; } } }} -) +); fn echo(mut req: Request, mut res: Response) { match req.uri { diff --git a/src/client/mod.rs b/src/client/mod.rs index 36fb6284..eccb2617 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -366,7 +366,7 @@ mod tests { Server: mock3\r\n\ \r\n\ " - }) + }); #[test] fn test_redirect_followall() { diff --git a/src/client/request.rs b/src/client/request.rs index ff1fa9c1..6787e86b 100644 --- a/src/client/request.rs +++ b/src/client/request.rs @@ -114,7 +114,7 @@ impl Request { } debug!("writing head: {} {} {}", self.method, uri, self.version); - try!(write!(&mut self.body, "{} {} {}", self.method, uri, self.version)) + try!(write!(&mut self.body, "{} {} {}", self.method, uri, self.version)); try!(self.body.write(LINE_ENDING)); diff --git a/src/header/common/accept.rs b/src/header/common/accept.rs index 13d91142..3080ebbd 100644 --- a/src/header/common/accept.rs +++ b/src/header/common/accept.rs @@ -23,7 +23,7 @@ use mime::Mime; #[deriving(Clone, PartialEq, Show)] pub struct Accept(pub Vec); -deref!(Accept -> Vec) +deref!(Accept -> Vec); impl Header for Accept { fn header_name(_: Option) -> &'static str { @@ -69,5 +69,5 @@ impl HeaderFormat for Accept { } } -bench_header!(bench, Accept, { vec![b"text/plain; q=0.5, text/html".to_vec()] }) +bench_header!(bench, Accept, { vec![b"text/plain; q=0.5, text/html".to_vec()] }); diff --git a/src/header/common/allow.rs b/src/header/common/allow.rs index 41489adb..07e17cd2 100644 --- a/src/header/common/allow.rs +++ b/src/header/common/allow.rs @@ -9,7 +9,7 @@ use super::util::{from_comma_delimited, fmt_comma_delimited}; #[deriving(Clone, PartialEq, Show)] pub struct Allow(pub Vec); -deref!(Allow -> Vec) +deref!(Allow -> Vec); impl Header for Allow { fn header_name(_: Option) -> &'static str { @@ -45,4 +45,5 @@ mod tests { } } -bench_header!(bench, Allow, { vec![b"OPTIONS,GET,PUT,POST,DELETE,HEAD,TRACE,CONNECT,PATCH,fOObAr".to_vec()] }) \ No newline at end of file +bench_header!(bench, Allow, { vec![b"OPTIONS,GET,PUT,POST,DELETE,HEAD,TRACE,CONNECT,PATCH,fOObAr".to_vec()] }); + diff --git a/src/header/common/authorization.rs b/src/header/common/authorization.rs index fe370c5d..b6708b95 100644 --- a/src/header/common/authorization.rs +++ b/src/header/common/authorization.rs @@ -191,5 +191,6 @@ mod tests { } -bench_header!(raw, Authorization, { vec![b"foo bar baz".to_vec()] }) -bench_header!(basic, Authorization, { vec![b"Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==".to_vec()] }) +bench_header!(raw, Authorization, { vec![b"foo bar baz".to_vec()] }); +bench_header!(basic, Authorization, { vec![b"Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==".to_vec()] }); + diff --git a/src/header/common/cache_control.rs b/src/header/common/cache_control.rs index f4563d49..1844c82b 100644 --- a/src/header/common/cache_control.rs +++ b/src/header/common/cache_control.rs @@ -7,7 +7,7 @@ use super::util::{from_one_comma_delimited, fmt_comma_delimited}; #[deriving(PartialEq, Clone, Show)] pub struct CacheControl(pub Vec); -deref!(CacheControl -> Vec) +deref!(CacheControl -> Vec); impl Header for CacheControl { fn header_name(_: Option) -> &'static str { @@ -162,4 +162,5 @@ mod tests { } } -bench_header!(normal, CacheControl, { vec![b"no-cache, private".to_vec(), b"max-age=100".to_vec()] }) +bench_header!(normal, CacheControl, { vec![b"no-cache, private".to_vec(), b"max-age=100".to_vec()] }); + diff --git a/src/header/common/connection.rs b/src/header/common/connection.rs index 2357aa12..2ae9b972 100644 --- a/src/header/common/connection.rs +++ b/src/header/common/connection.rs @@ -9,7 +9,7 @@ pub use self::ConnectionOption::{KeepAlive, Close, ConnectionHeader}; #[deriving(Clone, PartialEq, Show)] pub struct Connection(pub Vec); -deref!(Connection -> Vec) +deref!(Connection -> Vec); /// Values that can be in the `Connection` header. #[deriving(Clone, PartialEq)] @@ -66,6 +66,7 @@ impl HeaderFormat for Connection { } } -bench_header!(close, Connection, { vec![b"close".to_vec()] }) -bench_header!(keep_alive, Connection, { vec![b"keep-alive".to_vec()] }) -bench_header!(header, Connection, { vec![b"authorization".to_vec()] }) +bench_header!(close, Connection, { vec![b"close".to_vec()] }); +bench_header!(keep_alive, Connection, { vec![b"keep-alive".to_vec()] }); +bench_header!(header, Connection, { vec![b"authorization".to_vec()] }); + diff --git a/src/header/common/content_length.rs b/src/header/common/content_length.rs index 677c8d3c..32957b97 100644 --- a/src/header/common/content_length.rs +++ b/src/header/common/content_length.rs @@ -9,7 +9,7 @@ use super::util::from_one_raw_str; #[deriving(Copy, Clone, PartialEq, Show)] pub struct ContentLength(pub uint); -deref!(ContentLength -> uint) +deref!(ContentLength -> uint); impl Header for ContentLength { fn header_name(_: Option) -> &'static str { @@ -37,4 +37,5 @@ impl ContentLength { } } -bench_header!(bench, ContentLength, { vec![b"42349984".to_vec()] }) +bench_header!(bench, ContentLength, { vec![b"42349984".to_vec()] }); + diff --git a/src/header/common/content_type.rs b/src/header/common/content_type.rs index 5b786516..4b26dac5 100644 --- a/src/header/common/content_type.rs +++ b/src/header/common/content_type.rs @@ -10,7 +10,7 @@ use mime::Mime; #[deriving(Clone, PartialEq, Show)] pub struct ContentType(pub Mime); -deref!(ContentType -> Mime) +deref!(ContentType -> Mime); impl Header for ContentType { fn header_name(_: Option) -> &'static str { @@ -29,4 +29,5 @@ impl HeaderFormat for ContentType { } } -bench_header!(bench, ContentType, { vec![b"application/json; charset=utf-8".to_vec()] }) +bench_header!(bench, ContentType, { vec![b"application/json; charset=utf-8".to_vec()] }); + diff --git a/src/header/common/cookie.rs b/src/header/common/cookie.rs index 8e8cbd8d..a4717995 100644 --- a/src/header/common/cookie.rs +++ b/src/header/common/cookie.rs @@ -16,7 +16,7 @@ use cookie::CookieJar; #[deriving(Clone, PartialEq, Show)] pub struct Cookies(pub Vec); -deref!(Cookies -> Vec) +deref!(Cookies -> Vec); impl Header for Cookies { fn header_name(_: Option) -> &'static str { @@ -72,7 +72,7 @@ impl Cookies { jar } - /// Extracts all cookies from `CookieJar` and creates Cookie header. + /// Extracts all cookies from `CookieJar` and creates Cookie header. /// Useful for clients. pub fn from_cookie_jar(jar: &CookieJar) -> Cookies { Cookies(jar.iter().collect()) @@ -113,4 +113,5 @@ fn cookie_jar() { } -bench_header!(bench, Cookies, { vec![b"foo=bar; baz=quux".to_vec()] }) +bench_header!(bench, Cookies, { vec![b"foo=bar; baz=quux".to_vec()] }); + diff --git a/src/header/common/date.rs b/src/header/common/date.rs index 928a55c1..a33d16a4 100644 --- a/src/header/common/date.rs +++ b/src/header/common/date.rs @@ -9,7 +9,7 @@ use super::util::{from_one_raw_str, tm_from_str}; #[deriving(Copy, PartialEq, Clone)] pub struct Date(pub Tm); -deref!(Date -> Tm) +deref!(Date -> Tm); impl Header for Date { fn header_name(_: Option) -> &'static str { @@ -38,6 +38,7 @@ impl FromStr for Date { } } -bench_header!(imf_fixdate, Date, { vec![b"Sun, 07 Nov 1994 08:48:37 GMT".to_vec()] }) -bench_header!(rfc_850, Date, { vec![b"Sunday, 06-Nov-94 08:49:37 GMT".to_vec()] }) -bench_header!(asctime, Date, { vec![b"Sun Nov 6 08:49:37 1994".to_vec()] }) +bench_header!(imf_fixdate, Date, { vec![b"Sun, 07 Nov 1994 08:48:37 GMT".to_vec()] }); +bench_header!(rfc_850, Date, { vec![b"Sunday, 06-Nov-94 08:49:37 GMT".to_vec()] }); +bench_header!(asctime, Date, { vec![b"Sun Nov 6 08:49:37 1994".to_vec()] }); + diff --git a/src/header/common/etag.rs b/src/header/common/etag.rs index f98a65af..74a355d3 100644 --- a/src/header/common/etag.rs +++ b/src/header/common/etag.rs @@ -153,4 +153,5 @@ mod tests { } } -bench_header!(bench, Etag, { vec![b"W/\"nonemptytag\"".to_vec()] }) +bench_header!(bench, Etag, { vec![b"W/\"nonemptytag\"".to_vec()] }); + diff --git a/src/header/common/expires.rs b/src/header/common/expires.rs index 968ec023..f9dfe35c 100644 --- a/src/header/common/expires.rs +++ b/src/header/common/expires.rs @@ -8,7 +8,7 @@ use super::util::{from_one_raw_str, tm_from_str}; #[deriving(Copy, PartialEq, Clone)] pub struct Expires(pub Tm); -deref!(Expires -> Tm) +deref!(Expires -> Tm); impl Header for Expires { fn header_name(_: Option) -> &'static str { @@ -37,6 +37,7 @@ impl FromStr for Expires { } } -bench_header!(imf_fixdate, Expires, { vec![b"Sun, 07 Nov 1994 08:48:37 GMT".to_vec()] }) -bench_header!(rfc_850, Expires, { vec![b"Sunday, 06-Nov-94 08:49:37 GMT".to_vec()] }) -bench_header!(asctime, Expires, { vec![b"Sun Nov 6 08:49:37 1994".to_vec()] }) +bench_header!(imf_fixdate, Expires, { vec![b"Sun, 07 Nov 1994 08:48:37 GMT".to_vec()] }); +bench_header!(rfc_850, Expires, { vec![b"Sunday, 06-Nov-94 08:49:37 GMT".to_vec()] }); +bench_header!(asctime, Expires, { vec![b"Sun Nov 6 08:49:37 1994".to_vec()] }); + diff --git a/src/header/common/host.rs b/src/header/common/host.rs index f4753996..dd1554e9 100644 --- a/src/header/common/host.rs +++ b/src/header/common/host.rs @@ -95,5 +95,5 @@ mod tests { } } -bench_header!(bench, Host, { vec![b"foo.com:3000".to_vec()] }) +bench_header!(bench, Host, { vec![b"foo.com:3000".to_vec()] }); diff --git a/src/header/common/if_modified_since.rs b/src/header/common/if_modified_since.rs index 7524cd52..850e3dff 100644 --- a/src/header/common/if_modified_since.rs +++ b/src/header/common/if_modified_since.rs @@ -8,7 +8,7 @@ use super::util::{from_one_raw_str, tm_from_str}; #[deriving(Copy, PartialEq, Clone)] pub struct IfModifiedSince(pub Tm); -deref!(IfModifiedSince -> Tm) +deref!(IfModifiedSince -> Tm); impl Header for IfModifiedSince { fn header_name(_: Option) -> &'static str { @@ -37,6 +37,7 @@ impl FromStr for IfModifiedSince { } } -bench_header!(imf_fixdate, IfModifiedSince, { vec![b"Sun, 07 Nov 1994 08:48:37 GMT".to_vec()] }) -bench_header!(rfc_850, IfModifiedSince, { vec![b"Sunday, 06-Nov-94 08:49:37 GMT".to_vec()] }) -bench_header!(asctime, IfModifiedSince, { vec![b"Sun Nov 6 08:49:37 1994".to_vec()] }) +bench_header!(imf_fixdate, IfModifiedSince, { vec![b"Sun, 07 Nov 1994 08:48:37 GMT".to_vec()] }); +bench_header!(rfc_850, IfModifiedSince, { vec![b"Sunday, 06-Nov-94 08:49:37 GMT".to_vec()] }); +bench_header!(asctime, IfModifiedSince, { vec![b"Sun Nov 6 08:49:37 1994".to_vec()] }); + diff --git a/src/header/common/last_modified.rs b/src/header/common/last_modified.rs index 0b43fe1f..5606f093 100644 --- a/src/header/common/last_modified.rs +++ b/src/header/common/last_modified.rs @@ -8,7 +8,7 @@ use super::util::{from_one_raw_str, tm_from_str}; #[deriving(Copy, PartialEq, Clone)] pub struct LastModified(pub Tm); -deref!(LastModified -> Tm) +deref!(LastModified -> Tm); impl Header for LastModified { fn header_name(_: Option) -> &'static str { @@ -37,6 +37,7 @@ impl FromStr for LastModified { } } -bench_header!(imf_fixdate, LastModified, { vec![b"Sun, 07 Nov 1994 08:48:37 GMT".to_vec()] }) -bench_header!(rfc_850, LastModified, { vec![b"Sunday, 06-Nov-94 08:49:37 GMT".to_vec()] }) -bench_header!(asctime, LastModified, { vec![b"Sun Nov 6 08:49:37 1994".to_vec()] }) +bench_header!(imf_fixdate, LastModified, { vec![b"Sun, 07 Nov 1994 08:48:37 GMT".to_vec()] }); +bench_header!(rfc_850, LastModified, { vec![b"Sunday, 06-Nov-94 08:49:37 GMT".to_vec()] }); +bench_header!(asctime, LastModified, { vec![b"Sun Nov 6 08:49:37 1994".to_vec()] }); + diff --git a/src/header/common/location.rs b/src/header/common/location.rs index 0aa3f8a4..ea3b815d 100644 --- a/src/header/common/location.rs +++ b/src/header/common/location.rs @@ -16,7 +16,7 @@ use super::util::from_one_raw_str; #[deriving(Clone, PartialEq, Show)] pub struct Location(pub String); -deref!(Location -> String) +deref!(Location -> String); impl Header for Location { fn header_name(_: Option) -> &'static str { @@ -35,5 +35,5 @@ impl HeaderFormat for Location { } } -bench_header!(bench, Location, { vec![b"http://foo.com/hello:3000".to_vec()] }) +bench_header!(bench, Location, { vec![b"http://foo.com/hello:3000".to_vec()] }); diff --git a/src/header/common/mod.rs b/src/header/common/mod.rs index f26f6fb1..bbb4d37e 100644 --- a/src/header/common/mod.rs +++ b/src/header/common/mod.rs @@ -55,7 +55,7 @@ macro_rules! bench_header( } } } -) +); macro_rules! deref( ($from:ty -> $to:ty) => { @@ -71,7 +71,7 @@ macro_rules! deref( } } } -) +); /// Exposes the Accept header. pub mod accept; diff --git a/src/header/common/server.rs b/src/header/common/server.rs index 0b4085af..64c3ca1d 100644 --- a/src/header/common/server.rs +++ b/src/header/common/server.rs @@ -8,7 +8,7 @@ use super::util::from_one_raw_str; #[deriving(Clone, PartialEq, Show)] pub struct Server(pub String); -deref!(Server -> String) +deref!(Server -> String); impl Header for Server { fn header_name(_: Option) -> &'static str { @@ -27,5 +27,5 @@ impl HeaderFormat for Server { } } -bench_header!(bench, Server, { vec![b"Some String".to_vec()] }) +bench_header!(bench, Server, { vec![b"Some String".to_vec()] }); diff --git a/src/header/common/set_cookie.rs b/src/header/common/set_cookie.rs index 033445ff..aee732d1 100644 --- a/src/header/common/set_cookie.rs +++ b/src/header/common/set_cookie.rs @@ -13,7 +13,7 @@ use cookie::CookieJar; #[deriving(Clone, PartialEq, Show)] pub struct SetCookie(pub Vec); -deref!(SetCookie -> Vec) +deref!(SetCookie -> Vec); impl Header for SetCookie { fn header_name(_: Option) -> &'static str { @@ -111,3 +111,4 @@ fn cookie_jar() { assert_eq!(jar.encrypted().find("foo"), new_jar.encrypted().find("foo")); assert_eq!(jar.iter().collect::>(), new_jar.iter().collect::>()); } + diff --git a/src/header/common/transfer_encoding.rs b/src/header/common/transfer_encoding.rs index e86f5b38..e0572cf0 100644 --- a/src/header/common/transfer_encoding.rs +++ b/src/header/common/transfer_encoding.rs @@ -21,7 +21,7 @@ use self::Encoding::{Chunked, Gzip, Deflate, Compress, EncodingExt}; #[deriving(Clone, PartialEq, Show)] pub struct TransferEncoding(pub Vec); -deref!(TransferEncoding -> Vec) +deref!(TransferEncoding -> Vec); /// A value to be used with the `Transfer-Encoding` header. /// @@ -87,5 +87,6 @@ impl HeaderFormat for TransferEncoding { } } -bench_header!(normal, TransferEncoding, { vec![b"chunked, gzip".to_vec()] }) -bench_header!(ext, TransferEncoding, { vec![b"ext".to_vec()] }) +bench_header!(normal, TransferEncoding, { vec![b"chunked, gzip".to_vec()] }); +bench_header!(ext, TransferEncoding, { vec![b"ext".to_vec()] }); + diff --git a/src/header/common/upgrade.rs b/src/header/common/upgrade.rs index 4083c84d..296478b8 100644 --- a/src/header/common/upgrade.rs +++ b/src/header/common/upgrade.rs @@ -9,7 +9,7 @@ use self::Protocol::{WebSocket, ProtocolExt}; #[deriving(Clone, PartialEq, Show)] pub struct Upgrade(pub Vec); -deref!(Upgrade -> Vec) +deref!(Upgrade -> Vec); /// Protocol values that can appear in the Upgrade header. #[deriving(Clone, PartialEq)] @@ -55,4 +55,5 @@ impl HeaderFormat for Upgrade { } } -bench_header!(bench, Upgrade, { vec![b"HTTP/2.0, RTA/x11, websocket".to_vec()] }) +bench_header!(bench, Upgrade, { vec![b"HTTP/2.0, RTA/x11, websocket".to_vec()] }); + diff --git a/src/header/common/user_agent.rs b/src/header/common/user_agent.rs index d201e4b1..f35e7cbd 100644 --- a/src/header/common/user_agent.rs +++ b/src/header/common/user_agent.rs @@ -8,7 +8,7 @@ use super::util::from_one_raw_str; #[deriving(Clone, PartialEq, Show)] pub struct UserAgent(pub String); -deref!(UserAgent -> String) +deref!(UserAgent -> String); impl Header for UserAgent { fn header_name(_: Option) -> &'static str { @@ -27,5 +27,5 @@ impl HeaderFormat for UserAgent { } } -bench_header!(bench, UserAgent, { vec![b"cargo bench".to_vec()] }) +bench_header!(bench, UserAgent, { vec![b"cargo bench".to_vec()] }); diff --git a/src/header/mod.rs b/src/header/mod.rs index 086bbb75..01cb3f80 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -458,7 +458,7 @@ impl FromStr for CaseInsensitive { impl Clone for CaseInsensitive { fn clone(&self) -> CaseInsensitive { - CaseInsensitive((*self.0).clone().into_cow()) + CaseInsensitive(self.0.clone().into_cow()) } } diff --git a/src/http.rs b/src/http.rs index 12657e6e..b02a09a1 100644 --- a/src/http.rs +++ b/src/http.rs @@ -588,7 +588,7 @@ pub struct RawStatus(pub u16, pub SendStr); impl Clone for RawStatus { fn clone(&self) -> RawStatus { - RawStatus(self.0, (*self.1).clone().into_cow()) + RawStatus(self.0, self.1.clone().into_cow()) } } diff --git a/src/lib.rs b/src/lib.rs index e993737c..3e199ce6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -156,7 +156,7 @@ macro_rules! todo( ($($arg:tt)*) => (if cfg!(not(ndebug)) { format_args!(|args| log!(5, "TODO: {}", args), $($arg)*) }) -) +); #[allow(dead_code)] struct Trace; @@ -172,7 +172,7 @@ macro_rules! trace( ($($arg:tt)*) => (if cfg!(not(ndebug)) { format_args!(|args| log!(5, "{}\n{}", args, ::Trace), $($arg)*) }) -) +); macro_rules! inspect( ($name:expr, $value:expr) => ({ @@ -180,7 +180,7 @@ macro_rules! inspect( debug!("inspect: {} = {}", $name, v); v }) -) +); #[cfg(test)] #[macro_escape] diff --git a/src/mock.rs b/src/mock.rs index fdecd5e7..6f4867fb 100644 --- a/src/mock.rs +++ b/src/mock.rs @@ -104,4 +104,5 @@ macro_rules! mock_connector ( } ) -) +); + diff --git a/src/server/mod.rs b/src/server/mod.rs index 0ce996bb..a3fc9039 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -38,7 +38,7 @@ macro_rules! try_option( None => return None } }} -) +); impl Server { /// Creates a new server that will handle `HttpStream`s. diff --git a/src/server/request.rs b/src/server/request.rs index d43b27d4..b35efcc5 100644 --- a/src/server/request.rs +++ b/src/server/request.rs @@ -80,7 +80,7 @@ mod tests { macro_rules! sock( ($s:expr) => (::std::str::from_str::<::std::io::net::ip::SocketAddr>($s).unwrap()) - ) + ); #[test] fn test_get_empty_body() {