diff --git a/Cargo.lock b/Cargo.lock index ca74a0a..8856b03 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "afire" -version = "2.2.0" +version = "2.2.1" dependencies = [ "afire", ] diff --git a/Cargo.toml b/Cargo.toml index 1a8826a..8e6a8a0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ authors = ["Connor Slade "] edition = "2018" name = "afire" -version = "2.2.0" +version = "2.2.1" categories = ["network-programming", "web-programming::http-server"] description = "🔥 A blazing fast web framework for Rust" @@ -29,4 +29,4 @@ tracing = [] afire = { path = ".", features = ["extensions"] } [package.metadata.docs.rs] -rustc-args = ["--cfg", "docsrs"] +all-features = true diff --git a/Changelog.md b/Changelog.md index a0817b1..404f42c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,14 @@ +# 2.2.1 + +August 20, 2023 + +- Properly support `ErrorKind::Interrupted` on streaming responses. + Previously if a Reader returned any error, afire would just print an error and close the socket. +- Build extension docs on docs.rs + # 2.2.0 -July, 02, 2023 +July 02, 2023 - Use binary search on ServeStatic MMIE types (save those clock cycles) - Some optimizations throughout afire @@ -12,7 +20,6 @@ July, 02, 2023 This allows for using `HeaderType`s as well as strings to set the header. - Add a `HEAD` middleware that adds support for the HTTP HEAD method. - Update `ServeStatic` to send a Content-Length header when streaming a file. -- Build extension docs on docs.rs - Add a `TRACE` middleware that adds support for the HTTP TRACE method. - Add support for [Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events) (SSE). - Progress on Websocket support diff --git a/README.md b/README.md index dd0257e..4cbc104 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Just add the following to your `Cargo.toml`: ```toml [dependencies] -afire = "2.2.0" +afire = "2.2.1" ``` ## 📄 Info diff --git a/lib/internal/common.rs b/lib/internal/common.rs index 26f32de..e3bccc5 100644 --- a/lib/internal/common.rs +++ b/lib/internal/common.rs @@ -112,7 +112,7 @@ pub(crate) fn any_string(any: Box) -> Cow<'static, str /// Get the current time since the Unix Epoch. /// Will panic if the system time is before the Unix Epoch. -#[cfg(any(feature = "extensions", docsrs))] +#[cfg(feature = "extensions")] pub(crate) fn epoch() -> std::time::Duration { use std::time::{SystemTime, UNIX_EPOCH}; diff --git a/lib/lib.rs b/lib/lib.rs index b7ccc6b..38bb05a 100644 --- a/lib/lib.rs +++ b/lib/lib.rs @@ -61,9 +61,9 @@ pub mod prelude { } // Extra Features -#[cfg(any(feature = "extensions", docsrs))] +#[cfg(feature = "extensions")] mod extensions; -#[cfg(any(feature = "extensions", docsrs))] +#[cfg(feature = "extensions")] pub mod extension { //! Useful extensions to the base afire. //! Includes helpful middleware like Serve Static, Rate Limit and Logger. diff --git a/lib/response.rs b/lib/response.rs index 5959749..6e1b669 100644 --- a/lib/response.rs +++ b/lib/response.rs @@ -1,6 +1,6 @@ use std::cell::RefCell; use std::fmt::{self, Debug, Display, Formatter}; -use std::io::{Read, Write}; +use std::io::{ErrorKind, Read, Write}; use std::net::TcpStream; use std::sync::{Arc, Mutex}; @@ -361,10 +361,12 @@ impl ResponseBody { let data = data.get_mut(); loop { let mut chunk = vec![0; consts::CHUNK_SIZE]; - let read = data.read(&mut chunk)?; - if read == 0 { - break; - } + let read = match data.read(&mut chunk) { + Ok(0) => break, + Ok(n) => n, + Err(ref e) if e.kind() == ErrorKind::Interrupted => continue, + Err(e) => return Err(e.into()), + }; let mut section = format!("{read:X}\r\n").as_bytes().to_vec(); section.extend(&chunk[..read]);