Skip to content

Commit

Permalink
Merge pull request #47 from Basicprogrammer10/2.2.1-patch
Browse files Browse the repository at this point in the history
Fix #46
  • Loading branch information
connorslade authored Aug 20, 2023
2 parents ceb1c9a + 7ae43c9 commit 386caad
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
authors = ["Connor Slade <connor@connorcode.com>"]
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"
Expand All @@ -29,4 +29,4 @@ tracing = []
afire = { path = ".", features = ["extensions"] }

[package.metadata.docs.rs]
rustc-args = ["--cfg", "docsrs"]
all-features = true
11 changes: 9 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Just add the following to your `Cargo.toml`:

```toml
[dependencies]
afire = "2.2.0"
afire = "2.2.1"
```

## 📄 Info
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pub(crate) fn any_string(any: Box<dyn std::any::Any + Send>) -> 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};

Expand Down
4 changes: 2 additions & 2 deletions lib/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 7 additions & 5 deletions lib/response.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit 386caad

Please sign in to comment.