diff --git a/README.md b/README.md index c15e9e8532..cfca70f432 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Hello World Server: extern crate hyper; use std::io::Write; -use std::net::IpAddr; +use std::net::Ipv4Addr; use hyper::Server; use hyper::server::Request; @@ -42,7 +42,7 @@ fn hello(_: Request, mut res: Response) { } fn main() { - Server::http(hello).listen(IpAddr::new_v4(127, 0, 0, 1), 3000).unwrap(); + Server::http(hello).listen(Ipv4Addr::new(127, 0, 0, 1), 3000).unwrap(); } ``` diff --git a/benches/server.rs b/benches/server.rs index 9c71b26bfe..023b5fc3de 100644 --- a/benches/server.rs +++ b/benches/server.rs @@ -5,7 +5,7 @@ extern crate test; use test::Bencher; use std::io::{Read, Write}; -use std::net::IpAddr; +use std::net::Ipv4Addr; use hyper::method::Method::Get; use hyper::server::{Request, Response}; @@ -27,7 +27,7 @@ fn hyper_handle(_: Request, res: Response) { #[bench] fn bench_hyper(b: &mut Bencher) { let server = hyper::Server::http(hyper_handle); - let mut listener = server.listen(IpAddr::new_v4(127, 0, 0, 1), 0).unwrap(); + let mut listener = server.listen(Ipv4Addr::new(127, 0, 0, 1), 0).unwrap(); let url = hyper::Url::parse(&*format!("http://{}", listener.socket)).unwrap(); b.iter(|| request(url.clone())); diff --git a/examples/hello.rs b/examples/hello.rs index 4f49bc6266..dc9d3069a4 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -1,10 +1,9 @@ #![deny(warnings)] -#![feature(net)] extern crate hyper; extern crate env_logger; use std::io::Write; -use std::net::IpAddr; +use std::net::Ipv4Addr; use hyper::server::{Request, Response}; static PHRASE: &'static [u8] = b"Hello World!"; @@ -18,6 +17,6 @@ fn hello(_: Request, res: Response) { fn main() { env_logger::init().unwrap(); let _listening = hyper::Server::http(hello) - .listen(IpAddr::new_v4(127, 0, 0, 1), 3000).unwrap(); + .listen(Ipv4Addr::new(127, 0, 0, 1), 3000).unwrap(); println!("Listening on http://127.0.0.1:3000"); } diff --git a/examples/server.rs b/examples/server.rs index 666dc66a33..1ada938010 100644 --- a/examples/server.rs +++ b/examples/server.rs @@ -1,10 +1,9 @@ #![deny(warnings)] -#![feature(net)] extern crate hyper; extern crate env_logger; use std::io::{Write, copy}; -use std::net::IpAddr; +use std::net::Ipv4Addr; use hyper::{Get, Post}; use hyper::header::ContentLength; @@ -53,6 +52,6 @@ fn echo(mut req: Request, mut res: Response) { fn main() { env_logger::init().unwrap(); let server = Server::http(echo); - let _guard = server.listen(IpAddr::new_v4(127, 0, 0, 1), 1337).unwrap(); + let _guard = server.listen(Ipv4Addr::new(127, 0, 0, 1), 1337).unwrap(); println!("Listening on http://127.0.0.1:1337"); } diff --git a/src/lib.rs b/src/lib.rs index 77f6324558..5de90132c0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(core, collections, io, net, +#![feature(core, collections, io, std_misc, box_syntax, unsafe_destructor)] #![deny(missing_docs)] #![cfg_attr(test, deny(warnings))] diff --git a/src/net.rs b/src/net.rs index 5ed153c13e..c3c53f692d 100644 --- a/src/net.rs +++ b/src/net.rs @@ -215,8 +215,8 @@ impl NetworkListener for HttpListener { #[inline] fn socket_addr(&mut self) -> io::Result { match *self { - HttpListener::Http(ref mut tcp) => tcp.socket_addr(), - HttpListener::Https(ref mut tcp, _) => tcp.socket_addr(), + HttpListener::Http(ref mut tcp) => tcp.local_addr(), + HttpListener::Https(ref mut tcp, _) => tcp.local_addr(), } } } diff --git a/src/server/mod.rs b/src/server/mod.rs index 3407b9489c..3448db1fd5 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -1,7 +1,7 @@ //! HTTP Server use std::io::{BufReader, BufWriter, Write}; use std::marker::PhantomData; -use std::net::{IpAddr, SocketAddr}; +use std::net::{Ipv4Addr, SocketAddr}; use std::path::Path; use std::thread::{self, JoinGuard}; @@ -76,7 +76,7 @@ impl<'a, H: Handler + 'static> Server<'a, H, HttpListener> { impl<'a, H: Handler + 'static> Server<'a, H, HttpListener> { /// Binds to a socket, and starts handling connections using a task pool. - pub fn listen_threads(self, ip: IpAddr, port: u16, threads: usize) -> HttpResult { + pub fn listen_threads(self, ip: Ipv4Addr, port: u16, threads: usize) -> HttpResult { let addr = &(ip, port); let listener = try!(match self.ssl { Some((cert, key)) => HttpListener::https(addr, cert, key), @@ -86,7 +86,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 { + pub fn listen(self, ip: Ipv4Addr, port: u16) -> HttpResult { self.listen_threads(ip, port, num_cpus::get() * 5 / 4) } }