refactor(error): remove redundant parts of error names
The old names followed the old style of including the module name and "Error" in each variant. The new style is to refer to an error from its owning module, and variants are now scoped to their enum, so there's no need to include the enum name in the variant name. BREAKING CHANGE: The terms `Http` and `Error` have been removed from the Error type and its variants. `HttpError` should now be accessed as `hyper::Error`, and variants like `HttpIoError` should be accessed as `Error::Io`.
This commit is contained in:
@@ -33,8 +33,7 @@ pub use self::response::Response;
|
||||
|
||||
pub use net::{Fresh, Streaming};
|
||||
|
||||
use HttpError::HttpIoError;
|
||||
use {HttpResult};
|
||||
use Error;
|
||||
use buffer::BufReader;
|
||||
use header::{Headers, Expect};
|
||||
use http;
|
||||
@@ -113,7 +112,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<T: ToSocketAddrs>(self, addr: T, threads: usize) -> HttpResult<Listening> {
|
||||
pub fn listen_threads<T: ToSocketAddrs>(self, addr: T, threads: usize) -> ::Result<Listening> {
|
||||
let listener = try!(match self.ssl {
|
||||
Some(SslConfig::CertAndKey(cert, key)) => HttpListener::https(addr, cert, key),
|
||||
Some(SslConfig::Context(ssl_context)) => HttpListener::https_with_context(addr, ssl_context),
|
||||
@@ -123,7 +122,7 @@ impl<'a, H: Handler + 'static> Server<'a, H, HttpListener> {
|
||||
}
|
||||
|
||||
/// Binds to a socket and starts handling connections.
|
||||
pub fn listen<T: ToSocketAddrs>(self, addr: T) -> HttpResult<Listening> {
|
||||
pub fn listen<T: ToSocketAddrs>(self, addr: T) -> ::Result<Listening> {
|
||||
self.listen_threads(addr, num_cpus::get() * 5 / 4)
|
||||
}
|
||||
}
|
||||
@@ -133,12 +132,12 @@ H: Handler + 'static,
|
||||
L: NetworkListener<Stream=S> + Send + 'static,
|
||||
S: NetworkStream + Clone + Send> Server<'a, H, L> {
|
||||
/// Creates a new server that will handle `HttpStream`s.
|
||||
pub fn with_listener(self, listener: L, threads: usize) -> HttpResult<Listening> {
|
||||
pub fn with_listener(self, listener: L, threads: usize) -> ::Result<Listening> {
|
||||
with_listener(self.handler, listener, threads)
|
||||
}
|
||||
}
|
||||
|
||||
fn with_listener<H, L>(handler: H, mut listener: L, threads: usize) -> HttpResult<Listening>
|
||||
fn with_listener<H, L>(handler: H, mut listener: L, threads: usize) -> ::Result<Listening>
|
||||
where H: Handler + 'static,
|
||||
L: NetworkListener + Send + 'static {
|
||||
let socket = try!(listener.local_addr());
|
||||
@@ -175,11 +174,11 @@ where S: NetworkStream + Clone, H: Handler {
|
||||
while keep_alive {
|
||||
let req = match Request::new(&mut rdr, addr) {
|
||||
Ok(req) => req,
|
||||
Err(HttpIoError(ref e)) if e.kind() == ErrorKind::ConnectionAborted => {
|
||||
Err(Error::Io(ref e)) if e.kind() == ErrorKind::ConnectionAborted => {
|
||||
trace!("tcp closed, cancelling keep-alive loop");
|
||||
break;
|
||||
}
|
||||
Err(HttpIoError(e)) => {
|
||||
Err(Error::Io(e)) => {
|
||||
debug!("ioerror in keepalive loop = {:?}", e);
|
||||
break;
|
||||
}
|
||||
@@ -235,7 +234,7 @@ impl Drop for Listening {
|
||||
|
||||
impl Listening {
|
||||
/// Stop the server from listening to its socket address.
|
||||
pub fn close(&mut self) -> HttpResult<()> {
|
||||
pub fn close(&mut self) -> ::Result<()> {
|
||||
let _ = self._guard.take();
|
||||
debug!("closing server");
|
||||
//try!(self.acceptor.close());
|
||||
|
||||
Reference in New Issue
Block a user