diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
index a068070ff..53f22df63 100644
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
version:
- - 1.42.0 # MSRV
+ - 1.46.0 # MSRV
- stable
- nightly
@@ -30,6 +30,13 @@ jobs:
profile: minimal
override: true
+ - name: Generate Cargo.lock
+ uses: actions-rs/cargo@v1
+ with:
+ command: generate-lockfile
+ - name: Cache Dependencies
+ uses: Swatinem/rust-cache@v1.0.1
+
- name: check build
uses: actions-rs/cargo@v1
with:
@@ -58,12 +65,17 @@ jobs:
args: --package=awc --no-default-features --features=rustls -- --nocapture
- name: Generate coverage file
- if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
+ if: matrix.version == 'stable' && github.ref == 'refs/heads/master'
run: |
cargo install cargo-tarpaulin --vers "^0.13"
cargo tarpaulin --out Xml
- name: Upload to Codecov
- if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
+ if: matrix.version == 'stable' && github.ref == 'refs/heads/master'
uses: codecov/codecov-action@v1
with:
file: cobertura.xml
+
+ - name: Clear the cargo caches
+ run: |
+ cargo install cargo-cache --no-default-features --features ci-autoclean
+ cargo-cache
diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml
index dc8558ac1..6b5366faf 100644
--- a/.github/workflows/macos.yml
+++ b/.github/workflows/macos.yml
@@ -29,6 +29,13 @@ jobs:
profile: minimal
override: true
+ - name: Generate Cargo.lock
+ uses: actions-rs/cargo@v1
+ with:
+ command: generate-lockfile
+ - name: Cache Dependencies
+ uses: Swatinem/rust-cache@v1.0.1
+
- name: check build
uses: actions-rs/cargo@v1
with:
@@ -42,3 +49,8 @@ jobs:
args: --all --all-features --no-fail-fast -- --nocapture
--skip=test_h2_content_length
--skip=test_reading_deflate_encoding_large_random_rustls
+
+ - name: Clear the cargo caches
+ run: |
+ cargo install cargo-cache --no-default-features --features ci-autoclean
+ cargo-cache
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
index d53d50a61..d3de72a61 100644
--- a/.github/workflows/windows.yml
+++ b/.github/workflows/windows.yml
@@ -41,6 +41,13 @@ jobs:
Get-ChildItem C:\vcpkg\installed\x64-windows\bin
Get-ChildItem C:\vcpkg\installed\x64-windows\lib
+ - name: Generate Cargo.lock
+ uses: actions-rs/cargo@v1
+ with:
+ command: generate-lockfile
+ - name: Cache Dependencies
+ uses: Swatinem/rust-cache@v1.0.1
+
- name: check build
uses: actions-rs/cargo@v1
with:
@@ -62,3 +69,8 @@ jobs:
--skip=test_connection_force_close
--skip=test_connection_server_close
--skip=test_connection_wait_queue_force_close
+
+ - name: Clear the cargo caches
+ run: |
+ cargo install cargo-cache --no-default-features --features ci-autoclean
+ cargo-cache
diff --git a/CHANGES.md b/CHANGES.md
index da04c5aa3..fa56acc17 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -4,6 +4,7 @@
### Changed
* Bumped `rand` to `0.8`
* Rename `Handler` to `HandlerService` and rename `Factory` to `Handler`. [#1852]
+* MSRV is now 1.46.0.
### Fixed
* added the actual parsing error to `test::read_body_json` [#1812]
diff --git a/README.md b/README.md
index b9f2b7594..62ee50243 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@
[](https://crates.io/crates/actix-web)
[](https://docs.rs/actix-web/3.3.2)
-[](https://blog.rust-lang.org/2020/03/12/Rust-1.42.html)
+[](https://blog.rust-lang.org/2020/03/12/Rust-1.46.html)

[](https://deps.rs/crate/actix-web/3.3.2)
@@ -34,7 +34,7 @@
* Middlewares ([Logger, Session, CORS, etc](https://actix.rs/docs/middleware/))
* Includes an async [HTTP client](https://actix.rs/actix-web/actix_web/client/index.html)
* Supports [Actix actor framework](https://github.com/actix/actix)
-* Runs on stable Rust 1.42+
+* Runs on stable Rust 1.46+
## Documentation
diff --git a/actix-files/CHANGES.md b/actix-files/CHANGES.md
index 86e5e6563..49768419b 100644
--- a/actix-files/CHANGES.md
+++ b/actix-files/CHANGES.md
@@ -1,6 +1,7 @@
# Changes
## Unreleased - 2020-xx-xx
+* `HttpRange::parse` now has its own error type.
## 0.5.0 - 2020-12-26
diff --git a/actix-files/README.md b/actix-files/README.md
index 2953b4458..463f20224 100644
--- a/actix-files/README.md
+++ b/actix-files/README.md
@@ -4,7 +4,7 @@
[](https://crates.io/crates/actix-files)
[](https://docs.rs/actix-files/0.5.0)
-[](https://blog.rust-lang.org/2020/03/12/Rust-1.42.html)
+[](https://blog.rust-lang.org/2020/03/12/Rust-1.46.html)

[](https://deps.rs/crate/actix-files/0.5.0)
@@ -16,4 +16,4 @@
- [API Documentation](https://docs.rs/actix-files/)
- [Example Project](https://github.com/actix/examples/tree/master/static_index)
- [Chat on Gitter](https://gitter.im/actix/actix-web)
-- Minimum supported Rust version: 1.42 or later
+- Minimum supported Rust version: 1.46 or later
diff --git a/actix-files/src/range.rs b/actix-files/src/range.rs
index e891ca7ec..e420ce414 100644
--- a/actix-files/src/range.rs
+++ b/actix-files/src/range.rs
@@ -1,3 +1,5 @@
+use derive_more::{Display, Error};
+
/// HTTP Range header representation.
#[derive(Debug, Clone, Copy)]
pub struct HttpRange {
@@ -11,17 +13,21 @@ pub struct HttpRange {
const PREFIX: &str = "bytes=";
const PREFIX_LEN: usize = 6;
+#[derive(Debug, Clone, Display, Error)]
+#[display(fmt = "Parse HTTP Range failed")]
+pub struct ParseRangeErr(#[error(not(source))] ());
+
impl HttpRange {
/// Parses Range HTTP header string as per RFC 2616.
///
/// `header` is HTTP Range header (e.g. `bytes=bytes=0-9`).
/// `size` is full size of response (file).
- pub fn parse(header: &str, size: u64) -> Result, ()> {
+ pub fn parse(header: &str, size: u64) -> Result, ParseRangeErr> {
if header.is_empty() {
return Ok(Vec::new());
}
if !header.starts_with(PREFIX) {
- return Err(());
+ return Err(ParseRangeErr(()));
}
let size_sig = size as i64;
@@ -34,13 +40,14 @@ impl HttpRange {
.map(|ra| {
let mut start_end_iter = ra.split('-');
- let start_str = start_end_iter.next().ok_or(())?.trim();
- let end_str = start_end_iter.next().ok_or(())?.trim();
+ let start_str = start_end_iter.next().ok_or(ParseRangeErr(()))?.trim();
+ let end_str = start_end_iter.next().ok_or(ParseRangeErr(()))?.trim();
if start_str.is_empty() {
// If no start is specified, end specifies the
// range start relative to the end of the file.
- let mut length: i64 = end_str.parse().map_err(|_| ())?;
+ let mut length: i64 =
+ end_str.parse().map_err(|_| ParseRangeErr(()))?;
if length > size_sig {
length = size_sig;
@@ -51,10 +58,10 @@ impl HttpRange {
length: length as u64,
}))
} else {
- let start: i64 = start_str.parse().map_err(|_| ())?;
+ let start: i64 = start_str.parse().map_err(|_| ParseRangeErr(()))?;
if start < 0 {
- return Err(());
+ return Err(ParseRangeErr(()));
}
if start >= size_sig {
no_overlap = true;
@@ -65,10 +72,11 @@ impl HttpRange {
// If no end is specified, range extends to end of the file.
size_sig - start
} else {
- let mut end: i64 = end_str.parse().map_err(|_| ())?;
+ let mut end: i64 =
+ end_str.parse().map_err(|_| ParseRangeErr(()))?;
if start > end {
- return Err(());
+ return Err(ParseRangeErr(()));
}
if end >= size_sig {
@@ -89,7 +97,7 @@ impl HttpRange {
let ranges: Vec = all_ranges.into_iter().filter_map(|x| x).collect();
if no_overlap && ranges.is_empty() {
- return Err(());
+ return Err(ParseRangeErr(()));
}
Ok(ranges)
@@ -333,8 +341,7 @@ mod tests {
if expected.is_empty() {
continue;
} else {
- assert!(
- false,
+ panic!(
"parse({}, {}) returned error {:?}",
header,
size,
@@ -346,28 +353,24 @@ mod tests {
let got = res.unwrap();
if got.len() != expected.len() {
- assert!(
- false,
+ panic!(
"len(parseRange({}, {})) = {}, want {}",
header,
size,
got.len(),
expected.len()
);
- continue;
}
for i in 0..expected.len() {
if got[i].start != expected[i].start {
- assert!(
- false,
+ panic!(
"parseRange({}, {})[{}].start = {}, want {}",
header, size, i, got[i].start, expected[i].start
)
}
if got[i].length != expected[i].length {
- assert!(
- false,
+ panic!(
"parseRange({}, {})[{}].length = {}, want {}",
header, size, i, got[i].length, expected[i].length
)
diff --git a/actix-http-test/README.md b/actix-http-test/README.md
index c847c8515..bca9a7976 100644
--- a/actix-http-test/README.md
+++ b/actix-http-test/README.md
@@ -12,4 +12,4 @@
- [API Documentation](https://docs.rs/actix-http-test)
- [Chat on Gitter](https://gitter.im/actix/actix-web)
-- Minimum Supported Rust Version (MSRV): 1.42.0
+- Minimum Supported Rust Version (MSRV): 1.46.0
diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md
index 81577688d..c43246bb0 100644
--- a/actix-http/CHANGES.md
+++ b/actix-http/CHANGES.md
@@ -4,6 +4,13 @@
### Changed
* Bumped `rand` to `0.8`
+### Removed
+* Deprecated `on_connect` methods have been removed. Prefer the new
+ `on_connect_ext` technique. [#1857]
+
+[#1857]: https://github.com/actix/actix-web/pull/1857
+
+
## 2.2.0 - 2020-11-25
### Added
* HttpResponse builders for 1xx status codes. [#1768]
diff --git a/actix-http/README.md b/actix-http/README.md
index 9103cd184..9dfb85e24 100644
--- a/actix-http/README.md
+++ b/actix-http/README.md
@@ -12,7 +12,7 @@
- [API Documentation](https://docs.rs/actix-http)
- [Chat on Gitter](https://gitter.im/actix/actix-web)
-- Minimum Supported Rust Version (MSRV): 1.42.0
+- Minimum Supported Rust Version (MSRV): 1.46.0
## Example
diff --git a/actix-http/src/builder.rs b/actix-http/src/builder.rs
index b28c69761..df1b332c1 100644
--- a/actix-http/src/builder.rs
+++ b/actix-http/src/builder.rs
@@ -10,7 +10,6 @@ use crate::config::{KeepAlive, ServiceConfig};
use crate::error::Error;
use crate::h1::{Codec, ExpectHandler, H1Service, UpgradeHandler};
use crate::h2::H2Service;
-use crate::helpers::{Data, DataFactory};
use crate::request::Request;
use crate::response::Response;
use crate::service::HttpService;
@@ -28,8 +27,6 @@ pub struct HttpServiceBuilder> {
local_addr: Option,
expect: X,
upgrade: Option,
- // DEPRECATED: in favor of on_connect_ext
- on_connect: Option Box>>,
on_connect_ext: Option>>,
_t: PhantomData<(T, S)>,
}
@@ -51,7 +48,6 @@ where
local_addr: None,
expect: ExpectHandler,
upgrade: None,
- on_connect: None,
on_connect_ext: None,
_t: PhantomData,
}
@@ -141,7 +137,6 @@ where
local_addr: self.local_addr,
expect: expect.into_factory(),
upgrade: self.upgrade,
- on_connect: self.on_connect,
on_connect_ext: self.on_connect_ext,
_t: PhantomData,
}
@@ -171,26 +166,11 @@ where
local_addr: self.local_addr,
expect: self.expect,
upgrade: Some(upgrade.into_factory()),
- on_connect: self.on_connect,
on_connect_ext: self.on_connect_ext,
_t: PhantomData,
}
}
- /// Set on-connect callback.
- ///
- /// Called once per connection. Return value of the call is stored in request extensions.
- ///
- /// *SOFT DEPRECATED*: Prefer the `on_connect_ext` style callback.
- pub fn on_connect(mut self, f: F) -> Self
- where
- F: Fn(&T) -> I + 'static,
- I: Clone + 'static,
- {
- self.on_connect = Some(Rc::new(move |io| Box::new(Data(f(io)))));
- self
- }
-
/// Sets the callback to be run on connection establishment.
///
/// Has mutable access to a data container that will be merged into request extensions.
@@ -224,7 +204,6 @@ where
H1Service::with_config(cfg, service.into_factory())
.expect(self.expect)
.upgrade(self.upgrade)
- .on_connect(self.on_connect)
.on_connect_ext(self.on_connect_ext)
}
@@ -247,7 +226,6 @@ where
);
H2Service::with_config(cfg, service.into_factory())
- .on_connect(self.on_connect)
.on_connect_ext(self.on_connect_ext)
}
@@ -272,7 +250,6 @@ where
HttpService::with_config(cfg, service.into_factory())
.expect(self.expect)
.upgrade(self.upgrade)
- .on_connect(self.on_connect)
.on_connect_ext(self.on_connect_ext)
}
}
diff --git a/actix-http/src/clinu/mod.rs b/actix-http/src/clinu/mod.rs
new file mode 100644
index 000000000..e69de29bb
diff --git a/actix-http/src/h1/codec.rs b/actix-http/src/h1/codec.rs
index c9a62dc30..d5035df26 100644
--- a/actix-http/src/h1/codec.rs
+++ b/actix-http/src/h1/codec.rs
@@ -111,8 +111,8 @@ impl Decoder for Codec {
type Error = ParseError;
fn decode(&mut self, src: &mut BytesMut) -> Result