Merge pull request #137 from reem/crates-io-release
feat(cargo): prepare for crates.io release.
This commit is contained in:
45
Cargo.toml
45
Cargo.toml
@@ -1,32 +1,25 @@
|
||||
[package]
|
||||
|
||||
name = "hyper"
|
||||
version = "0.0.1"
|
||||
authors = ["Sean McArthur <sean.monstar@gmail.com>"]
|
||||
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 <sean.monstar@gmail.com>",
|
||||
"Jonathan Reem <jonathan.reem@gmail.com>"]
|
||||
|
||||
[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"
|
||||
|
||||
36
README.md
36
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)
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -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<MockStream> {
|
||||
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<MockStream> = 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();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -366,7 +366,7 @@ mod tests {
|
||||
Server: mock3\r\n\
|
||||
\r\n\
|
||||
"
|
||||
})
|
||||
});
|
||||
|
||||
#[test]
|
||||
fn test_redirect_followall() {
|
||||
|
||||
@@ -114,7 +114,7 @@ impl Request<Fresh> {
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ use mime::Mime;
|
||||
#[deriving(Clone, PartialEq, Show)]
|
||||
pub struct Accept(pub Vec<Mime>);
|
||||
|
||||
deref!(Accept -> Vec<Mime>)
|
||||
deref!(Accept -> Vec<Mime>);
|
||||
|
||||
impl Header for Accept {
|
||||
fn header_name(_: Option<Accept>) -> &'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()] });
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ use super::util::{from_comma_delimited, fmt_comma_delimited};
|
||||
#[deriving(Clone, PartialEq, Show)]
|
||||
pub struct Allow(pub Vec<Method>);
|
||||
|
||||
deref!(Allow -> Vec<Method>)
|
||||
deref!(Allow -> Vec<Method>);
|
||||
|
||||
impl Header for Allow {
|
||||
fn header_name(_: Option<Allow>) -> &'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()] })
|
||||
bench_header!(bench, Allow, { vec![b"OPTIONS,GET,PUT,POST,DELETE,HEAD,TRACE,CONNECT,PATCH,fOObAr".to_vec()] });
|
||||
|
||||
|
||||
@@ -191,5 +191,6 @@ mod tests {
|
||||
|
||||
}
|
||||
|
||||
bench_header!(raw, Authorization<String>, { vec![b"foo bar baz".to_vec()] })
|
||||
bench_header!(basic, Authorization<Basic>, { vec![b"Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==".to_vec()] })
|
||||
bench_header!(raw, Authorization<String>, { vec![b"foo bar baz".to_vec()] });
|
||||
bench_header!(basic, Authorization<Basic>, { vec![b"Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==".to_vec()] });
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use super::util::{from_one_comma_delimited, fmt_comma_delimited};
|
||||
#[deriving(PartialEq, Clone, Show)]
|
||||
pub struct CacheControl(pub Vec<CacheDirective>);
|
||||
|
||||
deref!(CacheControl -> Vec<CacheDirective>)
|
||||
deref!(CacheControl -> Vec<CacheDirective>);
|
||||
|
||||
impl Header for CacheControl {
|
||||
fn header_name(_: Option<CacheControl>) -> &'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()] });
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ pub use self::ConnectionOption::{KeepAlive, Close, ConnectionHeader};
|
||||
#[deriving(Clone, PartialEq, Show)]
|
||||
pub struct Connection(pub Vec<ConnectionOption>);
|
||||
|
||||
deref!(Connection -> Vec<ConnectionOption>)
|
||||
deref!(Connection -> Vec<ConnectionOption>);
|
||||
|
||||
/// 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()] });
|
||||
|
||||
|
||||
@@ -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<ContentLength>) -> &'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()] });
|
||||
|
||||
|
||||
@@ -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<ContentType>) -> &'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()] });
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ use cookie::CookieJar;
|
||||
#[deriving(Clone, PartialEq, Show)]
|
||||
pub struct Cookies(pub Vec<Cookie>);
|
||||
|
||||
deref!(Cookies -> Vec<Cookie>)
|
||||
deref!(Cookies -> Vec<Cookie>);
|
||||
|
||||
impl Header for Cookies {
|
||||
fn header_name(_: Option<Cookies>) -> &'static str {
|
||||
@@ -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()] });
|
||||
|
||||
|
||||
@@ -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<Date>) -> &'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()] });
|
||||
|
||||
|
||||
@@ -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()] });
|
||||
|
||||
|
||||
@@ -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<Expires>) -> &'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()] });
|
||||
|
||||
|
||||
@@ -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()] });
|
||||
|
||||
|
||||
@@ -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<IfModifiedSince>) -> &'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()] });
|
||||
|
||||
|
||||
@@ -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<LastModified>) -> &'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()] });
|
||||
|
||||
|
||||
@@ -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<Location>) -> &'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()] });
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<Server>) -> &'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()] });
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ use cookie::CookieJar;
|
||||
#[deriving(Clone, PartialEq, Show)]
|
||||
pub struct SetCookie(pub Vec<Cookie>);
|
||||
|
||||
deref!(SetCookie -> Vec<Cookie>)
|
||||
deref!(SetCookie -> Vec<Cookie>);
|
||||
|
||||
impl Header for SetCookie {
|
||||
fn header_name(_: Option<SetCookie>) -> &'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::<Vec<Cookie>>(), new_jar.iter().collect::<Vec<Cookie>>());
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ use self::Encoding::{Chunked, Gzip, Deflate, Compress, EncodingExt};
|
||||
#[deriving(Clone, PartialEq, Show)]
|
||||
pub struct TransferEncoding(pub Vec<Encoding>);
|
||||
|
||||
deref!(TransferEncoding -> Vec<Encoding>)
|
||||
deref!(TransferEncoding -> Vec<Encoding>);
|
||||
|
||||
/// 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()] });
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ use self::Protocol::{WebSocket, ProtocolExt};
|
||||
#[deriving(Clone, PartialEq, Show)]
|
||||
pub struct Upgrade(pub Vec<Protocol>);
|
||||
|
||||
deref!(Upgrade -> Vec<Protocol>)
|
||||
deref!(Upgrade -> Vec<Protocol>);
|
||||
|
||||
/// 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()] });
|
||||
|
||||
|
||||
@@ -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<UserAgent>) -> &'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()] });
|
||||
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -104,4 +104,5 @@ macro_rules! mock_connector (
|
||||
}
|
||||
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ macro_rules! try_option(
|
||||
None => return None
|
||||
}
|
||||
}}
|
||||
)
|
||||
);
|
||||
|
||||
impl Server<HttpListener> {
|
||||
/// Creates a new server that will handle `HttpStream`s.
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user