From 8a96e8fdd0c9ec9e99bdab01a7e2d66dd1964458 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Thu, 11 Jan 2018 23:49:53 -0800 Subject: [PATCH] disable compression for static files --- src/fs.rs | 2 ++ src/server/channel.rs | 9 +++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/fs.rs b/src/fs.rs index 467e90192..c49ca8546 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -83,6 +83,8 @@ impl Responder for NamedFile { fn respond_to(mut self, _: HttpRequest) -> Result { let mut resp = HTTPOk.build(); + use headers::ContentEncoding; + resp.content_encoding(ContentEncoding::Identity); if let Some(ext) = self.path().extension() { let mime = get_mime_type(&ext.to_string_lossy()); resp.content_type(format!("{}", mime).as_str()); diff --git a/src/server/channel.rs b/src/server/channel.rs index 92c5be65b..85c3ac4ef 100644 --- a/src/server/channel.rs +++ b/src/server/channel.rs @@ -112,16 +112,13 @@ impl Future for HttpChannel where T: IoStream, H: HttpHandler + 'sta } return result }, - Some(HttpProtocol::Unknown(_, _, ref mut io, ref mut buf)) => { + Some(HttpProtocol::Unknown(ref mut settings, _, ref mut io, ref mut buf)) => { match utils::read_from_io(io, buf) { - Ok(Async::Ready(0)) => { + Ok(Async::Ready(0)) | Err(_) => { debug!("Ignored premature client disconnection"); + settings.remove_channel(); return Err(()) }, - Err(err) => { - debug!("Ignored premature client disconnection {}", err); - return Err(()) - } _ => (), }