diff --git a/Cargo.toml b/Cargo.toml index 86821ee203..3eb9d2959e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ cookie = "*" httparse = "*" log = ">= 0.2.0" mime = "*" +num_cpus = "*" openssl = "*" rustc-serialize = "*" time = "*" diff --git a/benches/client.rs b/benches/client.rs index f0c27ffbe6..0363a6ce08 100644 --- a/benches/client.rs +++ b/benches/client.rs @@ -1,3 +1,4 @@ +#![deny(warnings)] #![feature(collections, io, net, test)] extern crate hyper; diff --git a/benches/server.rs b/benches/server.rs index 772cedc7d6..9c71b26bfe 100644 --- a/benches/server.rs +++ b/benches/server.rs @@ -1,4 +1,5 @@ -#![feature(io, net, test)] +#![deny(warnings)] +#![feature(net, test)] extern crate hyper; extern crate test; diff --git a/examples/client.rs b/examples/client.rs index 98b1155980..b2d32667c0 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -4,6 +4,7 @@ extern crate hyper; extern crate env_logger; use std::env; +use std::io; use hyper::Client; @@ -20,12 +21,12 @@ fn main() { let mut client = Client::new(); - let res = match client.get(&*url).send() { + let mut res = match client.get(&*url).send() { Ok(res) => res, Err(err) => panic!("Failed to connect: {:?}", err) }; println!("Response: {}", res.status); println!("Headers:\n{}", res.headers); - //TODO: add copy back when std::stdio impls std::io::Write. + io::copy(&mut res, &mut io::stdout()).unwrap(); } diff --git a/examples/hello.rs b/examples/hello.rs index d2bd437a58..4f49bc6266 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -1,5 +1,5 @@ #![deny(warnings)] -#![feature(io, net)] +#![feature(net)] extern crate hyper; extern crate env_logger; diff --git a/examples/server.rs b/examples/server.rs index f2d806e578..666dc66a33 100644 --- a/examples/server.rs +++ b/examples/server.rs @@ -1,5 +1,5 @@ #![deny(warnings)] -#![feature(io, net)] +#![feature(net)] extern crate hyper; extern crate env_logger; diff --git a/src/lib.rs b/src/lib.rs index ed937852b7..77f6324558 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(core, collections, io, net, os, path, +#![feature(core, collections, io, net, std_misc, box_syntax, unsafe_destructor)] #![deny(missing_docs)] #![cfg_attr(test, deny(warnings))] @@ -133,6 +133,7 @@ extern crate openssl; extern crate cookie; extern crate unicase; extern crate httparse; +extern crate num_cpus; #[macro_use] extern crate log; diff --git a/src/server/mod.rs b/src/server/mod.rs index 008af8c41a..3bc4343292 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -2,10 +2,11 @@ use std::io::{BufReader, BufWriter}; use std::marker::PhantomData; use std::net::{IpAddr, SocketAddr}; -use std::os; use std::path::Path; use std::thread::{self, JoinGuard}; +use num_cpus; + pub use self::request::Request; pub use self::response::Response; @@ -83,7 +84,7 @@ impl<'a, H: Handler + 'static> Server<'a, H, HttpListener> { /// Binds to a socket and starts handling connections. pub fn listen(self, ip: IpAddr, port: u16) -> HttpResult { - self.listen_threads(ip, port, os::num_cpus() * 5 / 4) + self.listen_threads(ip, port, num_cpus::get() * 5 / 4) } } impl<