fix(server): handle keep-alive closing

Closes #437
This commit is contained in:
Sean McArthur
2015-04-15 11:07:23 -07:00
parent dac2f4db8a
commit d9187713b2
2 changed files with 30 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
//! HTTP Server
use std::io::{BufWriter, Write};
use std::io::{ErrorKind, BufWriter, Write};
use std::marker::PhantomData;
use std::net::{SocketAddr, ToSocketAddrs};
use std::path::Path;
@@ -134,7 +134,11 @@ where S: NetworkStream + Clone, H: Handler {
while keep_alive {
let req = match Request::new(&mut rdr, addr) {
Ok(req) => req,
Err(e@HttpIoError(_)) => {
Err(HttpIoError(ref e)) if e.kind() == ErrorKind::ConnectionAborted => {
trace!("tcp closed, cancelling keep-alive loop");
break;
}
Err(HttpIoError(e)) => {
debug!("ioerror in keepalive loop = {:?}", e);
break;
}