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 bd00cb910..5a415ddc8 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -5,6 +5,7 @@
* Bumped `rand` to `0.8`
* Update `rust-tls` to `0.19.0`
* Rename `Handler` to `HandlerService` and rename `Factory` to `Handler`. [#1852]
+* MSRV is now 1.46.0.
### Fixed
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 3bb68e093..9dc7684ba 100644
--- a/actix-files/CHANGES.md
+++ b/actix-files/CHANGES.md
@@ -2,6 +2,7 @@
## Unreleased - 2020-xx-xx
* Update `bytes` to `1`.
+* `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 14c9adb70..3fb024591 100644
--- a/actix-http/CHANGES.md
+++ b/actix-http/CHANGES.md
@@ -6,6 +6,13 @@
* Upgrade `bytes` to `1`
* Upgrade `h2` to `0.3`
+### 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 de8f7ad03..ecb4327df 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,
}
@@ -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,
}
@@ -167,26 +162,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.
@@ -220,7 +200,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)
}
@@ -243,7 +222,6 @@ where
);
H2Service::with_config(cfg, service.into_factory())
- .on_connect(self.on_connect)
.on_connect_ext(self.on_connect_ext)
}
@@ -268,7 +246,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/dispatcher.rs b/actix-http/src/h1/dispatcher.rs
index d144fc58c..349a4a665 100644
--- a/actix-http/src/h1/dispatcher.rs
+++ b/actix-http/src/h1/dispatcher.rs
@@ -19,7 +19,6 @@ use crate::cloneable::CloneableService;
use crate::config::ServiceConfig;
use crate::error::{DispatchError, Error};
use crate::error::{ParseError, PayloadError};
-use crate::helpers::DataFactory;
use crate::httpmessage::HttpMessage;
use crate::request::Request;
use crate::response::Response;
@@ -96,7 +95,6 @@ where
service: CloneableService,
expect: CloneableService,
upgrade: Option>,
- on_connect: Option>,
on_connect_data: Extensions,
flags: Flags,
peer_addr: Option,
@@ -185,7 +183,6 @@ where
service: CloneableService,
expect: CloneableService,
upgrade: Option>,
- on_connect: Option>,
on_connect_data: Extensions,
peer_addr: Option,
) -> Self {
@@ -198,7 +195,6 @@ where
service,
expect,
upgrade,
- on_connect,
on_connect_data,
peer_addr,
)
@@ -214,7 +210,6 @@ where
service: CloneableService,
expect: CloneableService,
upgrade: Option>,
- on_connect: Option>,
on_connect_data: Extensions,
peer_addr: Option,
) -> Self {
@@ -247,7 +242,6 @@ where
service,
expect,
upgrade,
- on_connect,
on_connect_data,
flags,
peer_addr,
@@ -573,12 +567,6 @@ where
let pl = this.codec.message_type();
req.head_mut().peer_addr = *this.peer_addr;
- // DEPRECATED
- // set on_connect data
- if let Some(ref on_connect) = this.on_connect {
- on_connect.set(&mut req.extensions_mut());
- }
-
// merge on_connect_ext data into request extensions
req.extensions_mut().drain_from(this.on_connect_data);
@@ -1046,7 +1034,6 @@ mod tests {
CloneableService::new(ok_service()),
CloneableService::new(ExpectHandler),
None,
- None,
Extensions::new(),
None,
);
@@ -1087,7 +1074,6 @@ mod tests {
CloneableService::new(echo_path_service()),
CloneableService::new(ExpectHandler),
None,
- None,
Extensions::new(),
None,
);
@@ -1142,7 +1128,6 @@ mod tests {
CloneableService::new(echo_path_service()),
CloneableService::new(ExpectHandler),
None,
- None,
Extensions::new(),
None,
);
@@ -1192,7 +1177,6 @@ mod tests {
CloneableService::new(echo_payload_service()),
CloneableService::new(ExpectHandler),
None,
- None,
Extensions::new(),
None,
);
@@ -1264,7 +1248,6 @@ mod tests {
CloneableService::new(echo_path_service()),
CloneableService::new(ExpectHandler),
None,
- None,
Extensions::new(),
None,
);
@@ -1324,7 +1307,6 @@ mod tests {
CloneableService::new(ok_service()),
CloneableService::new(ExpectHandler),
Some(CloneableService::new(UpgradeHandler(PhantomData))),
- None,
Extensions::new(),
None,
);
diff --git a/actix-http/src/h1/service.rs b/actix-http/src/h1/service.rs
index 663949007..67f1127c7 100644
--- a/actix-http/src/h1/service.rs
+++ b/actix-http/src/h1/service.rs
@@ -15,7 +15,6 @@ use crate::body::MessageBody;
use crate::cloneable::CloneableService;
use crate::config::ServiceConfig;
use crate::error::{DispatchError, Error};
-use crate::helpers::DataFactory;
use crate::request::Request;
use crate::response::Response;
use crate::{ConnectCallback, Extensions};
@@ -30,7 +29,6 @@ pub struct H1Service {
cfg: ServiceConfig,
expect: X,
upgrade: Option,
- on_connect: Option Box>>,
on_connect_ext: Option>>,
_t: PhantomData,
}
@@ -53,7 +51,6 @@ where
srv: service.into_factory(),
expect: ExpectHandler,
upgrade: None,
- on_connect: None,
on_connect_ext: None,
_t: PhantomData,
}
@@ -213,7 +210,6 @@ where
cfg: self.cfg,
srv: self.srv,
upgrade: self.upgrade,
- on_connect: self.on_connect,
on_connect_ext: self.on_connect_ext,
_t: PhantomData,
}
@@ -230,21 +226,11 @@ where
cfg: self.cfg,
srv: self.srv,
expect: self.expect,
- on_connect: self.on_connect,
on_connect_ext: self.on_connect_ext,
_t: PhantomData,
}
}
- /// Set on connect callback.
- pub(crate) fn on_connect(
- mut self,
- f: Option Box>>,
- ) -> Self {
- self.on_connect = f;
- self
- }
-
/// Set on connect callback.
pub(crate) fn on_connect_ext(mut self, f: Option>>) -> Self {
self.on_connect_ext = f;
@@ -282,7 +268,6 @@ where
fut_upg: self.upgrade.as_ref().map(|f| f.new_service(())),
expect: None,
upgrade: None,
- on_connect: self.on_connect.clone(),
on_connect_ext: self.on_connect_ext.clone(),
cfg: Some(self.cfg.clone()),
_t: PhantomData,
@@ -312,7 +297,6 @@ where
fut_upg: Option,
expect: Option,
upgrade: Option,
- on_connect: Option Box>>,
on_connect_ext: Option>>,
cfg: Option,
_t: PhantomData<(T, B)>,
@@ -369,7 +353,6 @@ where
service,
this.expect.take().unwrap(),
this.upgrade.take(),
- this.on_connect.clone(),
this.on_connect_ext.clone(),
)
}))
@@ -386,7 +369,6 @@ where
srv: CloneableService,
expect: CloneableService,
upgrade: Option>,
- on_connect: Option Box>>,
on_connect_ext: Option>>,
cfg: ServiceConfig,
_t: PhantomData,
@@ -408,7 +390,6 @@ where
srv: S,
expect: X,
upgrade: Option,
- on_connect: Option Box>>,
on_connect_ext: Option>>,
) -> H1ServiceHandler {
H1ServiceHandler {
@@ -416,7 +397,6 @@ where
expect: CloneableService::new(expect),
upgrade: upgrade.map(CloneableService::new),
cfg,
- on_connect,
on_connect_ext,
_t: PhantomData,
}
@@ -483,8 +463,6 @@ where
}
fn call(&mut self, (io, addr): (T, Option)) -> Self::Future {
- let deprecated_on_connect = self.on_connect.as_ref().map(|handler| handler(&io));
-
let mut connect_extensions = Extensions::new();
if let Some(ref handler) = self.on_connect_ext {
// run on_connect_ext callback, populating connect extensions
@@ -497,7 +475,6 @@ where
self.srv.clone(),
self.expect.clone(),
self.upgrade.clone(),
- deprecated_on_connect,
connect_extensions,
addr,
)
diff --git a/actix-http/src/h2/dispatcher.rs b/actix-http/src/h2/dispatcher.rs
index 1be6157a9..4aeda942a 100644
--- a/actix-http/src/h2/dispatcher.rs
+++ b/actix-http/src/h2/dispatcher.rs
@@ -18,7 +18,6 @@ use crate::body::{BodySize, MessageBody, ResponseBody};
use crate::cloneable::CloneableService;
use crate::config::ServiceConfig;
use crate::error::{DispatchError, Error};
-use crate::helpers::DataFactory;
use crate::httpmessage::HttpMessage;
use crate::message::ResponseHead;
use crate::payload::Payload;
@@ -38,7 +37,6 @@ where
{
service: CloneableService,
connection: Connection,
- on_connect: Option>,
on_connect_data: Extensions,
config: ServiceConfig,
peer_addr: Option,
@@ -59,7 +57,6 @@ where
pub(crate) fn new(
service: CloneableService,
connection: Connection,
- on_connect: Option>,
on_connect_data: Extensions,
config: ServiceConfig,
timeout: Option,
@@ -86,7 +83,6 @@ where
config,
peer_addr,
connection,
- on_connect,
on_connect_data,
ka_expire,
ka_timer,
@@ -136,12 +132,6 @@ where
head.headers = parts.headers.into();
head.peer_addr = this.peer_addr;
- // DEPRECATED
- // set on_connect data
- if let Some(ref on_connect) = this.on_connect {
- on_connect.set(&mut req.extensions_mut());
- }
-
// merge on_connect_ext data into request extensions
req.extensions_mut().drain_from(&mut this.on_connect_data);
diff --git a/actix-http/src/h2/service.rs b/actix-http/src/h2/service.rs
index fc1ace6fa..719f3622c 100644
--- a/actix-http/src/h2/service.rs
+++ b/actix-http/src/h2/service.rs
@@ -20,7 +20,6 @@ use crate::body::MessageBody;
use crate::cloneable::CloneableService;
use crate::config::ServiceConfig;
use crate::error::{DispatchError, Error};
-use crate::helpers::DataFactory;
use crate::request::Request;
use crate::response::Response;
use crate::{ConnectCallback, Extensions};
@@ -31,7 +30,6 @@ use super::dispatcher::Dispatcher;
pub struct H2Service {
srv: S,
cfg: ServiceConfig,
- on_connect: Option Box>>,
on_connect_ext: Option>>,
_t: PhantomData<(T, B)>,
}
@@ -51,23 +49,12 @@ where
) -> Self {
H2Service {
cfg,
- on_connect: None,
on_connect_ext: None,
srv: service.into_factory(),
_t: PhantomData,
}
}
- /// Set on connect callback.
-
- pub(crate) fn on_connect(
- mut self,
- f: Option Box>>,
- ) -> Self {
- self.on_connect = f;
- self
- }
-
/// Set on connect callback.
pub(crate) fn on_connect_ext(mut self, f: Option>>) -> Self {
self.on_connect_ext = f;
@@ -212,7 +199,6 @@ where
H2ServiceResponse {
fut: self.srv.new_service(()),
cfg: Some(self.cfg.clone()),
- on_connect: self.on_connect.clone(),
on_connect_ext: self.on_connect_ext.clone(),
_t: PhantomData,
}
@@ -228,7 +214,6 @@ where
#[pin]
fut: S::Future,
cfg: Option,
- on_connect: Option Box>>,
on_connect_ext: Option>>,
_t: PhantomData,
}
@@ -251,7 +236,6 @@ where
let this = self.as_mut().project();
H2ServiceHandler::new(
this.cfg.take().unwrap(),
- this.on_connect.clone(),
this.on_connect_ext.clone(),
service,
)
@@ -266,7 +250,6 @@ where
{
srv: CloneableService,
cfg: ServiceConfig,
- on_connect: Option Box>>,
on_connect_ext: Option>>,
_t: PhantomData,
}
@@ -281,13 +264,11 @@ where
{
fn new(
cfg: ServiceConfig,
- on_connect: Option Box>>,
on_connect_ext: Option>>,
srv: S,
) -> H2ServiceHandler {
H2ServiceHandler {
cfg,
- on_connect,
on_connect_ext,
srv: CloneableService::new(srv),
_t: PhantomData,
@@ -317,8 +298,6 @@ where
}
fn call(&mut self, (io, addr): (T, Option)) -> Self::Future {
- let deprecated_on_connect = self.on_connect.as_ref().map(|handler| handler(&io));
-
let mut connect_extensions = Extensions::new();
if let Some(ref handler) = self.on_connect_ext {
// run on_connect_ext callback, populating connect extensions
@@ -330,7 +309,6 @@ where
Some(self.srv.clone()),
Some(self.cfg.clone()),
addr,
- deprecated_on_connect,
Some(connect_extensions),
server::handshake(io),
),
@@ -348,7 +326,6 @@ where
Option>,
Option,
Option,
- Option>,
Option,
Handshake,
),
@@ -384,7 +361,6 @@ where
ref mut srv,
ref mut config,
ref peer_addr,
- ref mut on_connect,
ref mut on_connect_data,
ref mut handshake,
) => match Pin::new(handshake).poll(cx) {
@@ -392,7 +368,6 @@ where
self.state = State::Incoming(Dispatcher::new(
srv.take().unwrap(),
conn,
- on_connect.take(),
on_connect_data.take().unwrap(),
config.take().unwrap(),
None,
diff --git a/actix-http/src/header/common/content_disposition.rs b/actix-http/src/header/common/content_disposition.rs
index 826cfef63..4c512acbe 100644
--- a/actix-http/src/header/common/content_disposition.rs
+++ b/actix-http/src/header/common/content_disposition.rs
@@ -318,9 +318,8 @@ impl ContentDisposition {
return Err(crate::error::ParseError::Header);
}
left = new_left;
- if param_name.ends_with('*') {
+ if let Some(param_name) = param_name.strip_suffix('*') {
// extended parameters
- let param_name = ¶m_name[..param_name.len() - 1]; // trim asterisk
let (ext_value, new_left) = split_once_and_trim(left, ';');
left = new_left;
let ext_value = header::parse_extended_value(ext_value)?;
diff --git a/actix-http/src/helpers.rs b/actix-http/src/helpers.rs
index ac0e0f118..13195f7db 100644
--- a/actix-http/src/helpers.rs
+++ b/actix-http/src/helpers.rs
@@ -3,8 +3,6 @@ use std::io;
use bytes::{BufMut, BytesMut};
use http::Version;
-use crate::extensions::Extensions;
-
const DIGITS_START: u8 = b'0';
pub(crate) fn write_status_line(version: Version, n: u16, bytes: &mut BytesMut) {
@@ -56,18 +54,6 @@ impl<'a> io::Write for Writer<'a> {
}
}
-pub(crate) trait DataFactory {
- fn set(&self, ext: &mut Extensions);
-}
-
-pub(crate) struct Data(pub(crate) T);
-
-impl DataFactory for Data {
- fn set(&self, ext: &mut Extensions) {
- ext.insert(self.0.clone())
- }
-}
-
#[cfg(test)]
mod tests {
use std::str::from_utf8;
diff --git a/actix-http/src/lib.rs b/actix-http/src/lib.rs
index 89d64fb77..94cc50a76 100644
--- a/actix-http/src/lib.rs
+++ b/actix-http/src/lib.rs
@@ -7,7 +7,6 @@
clippy::new_without_default,
clippy::borrow_interior_mutable_const
)]
-#![allow(clippy::manual_strip)] // Allow this to keep MSRV(1.42).
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
diff --git a/actix-http/src/service.rs b/actix-http/src/service.rs
index af2be296e..acc21b1b6 100644
--- a/actix-http/src/service.rs
+++ b/actix-http/src/service.rs
@@ -17,7 +17,6 @@ use crate::builder::HttpServiceBuilder;
use crate::cloneable::CloneableService;
use crate::config::{KeepAlive, ServiceConfig};
use crate::error::{DispatchError, Error};
-use crate::helpers::DataFactory;
use crate::request::Request;
use crate::response::Response;
use crate::{h1, h2::Dispatcher, ConnectCallback, Extensions, Protocol};
@@ -28,8 +27,6 @@ pub struct HttpService {
cfg: ServiceConfig,
expect: X,
upgrade: Option,
- // DEPRECATED: in favor of on_connect_ext
- on_connect: Option Box>>,
on_connect_ext: Option>>,
_t: PhantomData,
}
@@ -67,7 +64,6 @@ where
srv: service.into_factory(),
expect: h1::ExpectHandler,
upgrade: None,
- on_connect: None,
on_connect_ext: None,
_t: PhantomData,
}
@@ -83,7 +79,6 @@ where
srv: service.into_factory(),
expect: h1::ExpectHandler,
upgrade: None,
- on_connect: None,
on_connect_ext: None,
_t: PhantomData,
}
@@ -116,7 +111,6 @@ where
cfg: self.cfg,
srv: self.srv,
upgrade: self.upgrade,
- on_connect: self.on_connect,
on_connect_ext: self.on_connect_ext,
_t: PhantomData,
}
@@ -138,21 +132,11 @@ where
cfg: self.cfg,
srv: self.srv,
expect: self.expect,
- on_connect: self.on_connect,
on_connect_ext: self.on_connect_ext,
_t: PhantomData,
}
}
- /// Set on connect callback.
- pub(crate) fn on_connect(
- mut self,
- f: Option Box>>,
- ) -> Self {
- self.on_connect = f;
- self
- }
-
/// Set connect callback with mutable access to request data container.
pub(crate) fn on_connect_ext(mut self, f: Option>>) -> Self {
self.on_connect_ext = f;
@@ -362,7 +346,6 @@ where
fut_upg: self.upgrade.as_ref().map(|f| f.new_service(())),
expect: None,
upgrade: None,
- on_connect: self.on_connect.clone(),
on_connect_ext: self.on_connect_ext.clone(),
cfg: self.cfg.clone(),
_t: PhantomData,
@@ -386,7 +369,6 @@ where
fut_upg: Option,
expect: Option,
upgrade: Option,
- on_connect: Option Box>>,
on_connect_ext: Option>>,
cfg: ServiceConfig,
_t: PhantomData<(T, B)>,
@@ -446,7 +428,6 @@ where
service,
this.expect.take().unwrap(),
this.upgrade.take(),
- this.on_connect.clone(),
this.on_connect_ext.clone(),
)
}))
@@ -464,7 +445,6 @@ where
expect: CloneableService,
upgrade: Option>,
cfg: ServiceConfig,
- on_connect: Option Box>>,
on_connect_ext: Option>>,
_t: PhantomData,
}
@@ -486,12 +466,10 @@ where
srv: S,
expect: X,
upgrade: Option,
- on_connect: Option Box>>,
on_connect_ext: Option>>,
) -> HttpServiceHandler {
HttpServiceHandler {
cfg,
- on_connect,
on_connect_ext,
srv: CloneableService::new(srv),
expect: CloneableService::new(expect),
@@ -567,7 +545,6 @@ where
) -> Self::Future {
let mut connect_extensions = Extensions::new();
- let deprecated_on_connect = self.on_connect.as_ref().map(|handler| handler(&io));
if let Some(ref handler) = self.on_connect_ext {
handler(&io, &mut connect_extensions);
}
@@ -578,7 +555,6 @@ where
server::handshake(io),
self.cfg.clone(),
self.srv.clone(),
- deprecated_on_connect,
connect_extensions,
peer_addr,
))),
@@ -591,7 +567,6 @@ where
self.srv.clone(),
self.expect.clone(),
self.upgrade.clone(),
- deprecated_on_connect,
connect_extensions,
peer_addr,
)),
@@ -620,7 +595,6 @@ where
Handshake,
ServiceConfig,
CloneableService,
- Option>,
Extensions,
Option,
)>,
@@ -697,12 +671,10 @@ where
} else {
panic!()
};
- let (_, cfg, srv, on_connect, on_connect_data, peer_addr) =
- data.take().unwrap();
+ let (_, cfg, srv, on_connect_data, peer_addr) = data.take().unwrap();
self.set(State::H2(Dispatcher::new(
srv,
conn,
- on_connect,
on_connect_data,
cfg,
None,
diff --git a/actix-http/tests/test_openssl.rs b/actix-http/tests/test_openssl.rs
index 05f01d240..6b80bad0a 100644
--- a/actix-http/tests/test_openssl.rs
+++ b/actix-http/tests/test_openssl.rs
@@ -410,10 +410,8 @@ async fn test_h2_service_error() {
async fn test_h2_on_connect() {
let srv = test_server(move || {
HttpService::build()
- .on_connect(|_| 10usize)
.on_connect_ext(|_, data| data.insert(20isize))
.h2(|req: Request| {
- assert!(req.extensions().contains::());
assert!(req.extensions().contains::());
ok::<_, ()>(Response::Ok().finish())
})
diff --git a/actix-http/tests/test_server.rs b/actix-http/tests/test_server.rs
index 1a054b5fe..fa1aeb695 100644
--- a/actix-http/tests/test_server.rs
+++ b/actix-http/tests/test_server.rs
@@ -662,10 +662,8 @@ async fn test_h1_service_error() {
async fn test_h1_on_connect() {
let srv = test_server(|| {
HttpService::build()
- .on_connect(|_| 10usize)
.on_connect_ext(|_, data| data.insert(20isize))
.h1(|req: Request| {
- assert!(req.extensions().contains::());
assert!(req.extensions().contains::());
future::ok::<_, ()>(Response::Ok().finish())
})
diff --git a/actix-web-codegen/README.md b/actix-web-codegen/README.md
index 283591e86..887502075 100644
--- a/actix-web-codegen/README.md
+++ b/actix-web-codegen/README.md
@@ -4,7 +4,7 @@
[](https://crates.io/crates/actix-web-codegen)
[](https://docs.rs/actix-web-codegen/0.4.0/actix_web_codegen/)
-[](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://travis-ci.org/actix/actix-web)
[](https://codecov.io/gh/actix/actix-web)
[](https://gitter.im/actix/actix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -14,7 +14,7 @@
- [API Documentation](https://docs.rs/actix-web-codegen)
- [Chat on Gitter](https://gitter.im/actix/actix-web)
- Cargo package: [actix-web-codegen](https://crates.io/crates/actix-web-codegen)
-- Minimum supported Rust version: 1.42 or later.
+- Minimum supported Rust version: 1.46 or later.
## Compile Testing
Uses the [`trybuild`] crate. All compile fail tests should include a stderr file generated by `trybuild`. See the [workflow section](https://github.com/dtolnay/trybuild#workflow) of the trybuild docs for info on how to do this.
diff --git a/actix-web-codegen/tests/trybuild.rs b/actix-web-codegen/tests/trybuild.rs
index 6c7c58986..d2d8a38f5 100644
--- a/actix-web-codegen/tests/trybuild.rs
+++ b/actix-web-codegen/tests/trybuild.rs
@@ -6,31 +6,15 @@ fn compile_macros() {
t.compile_fail("tests/trybuild/simple-fail.rs");
t.pass("tests/trybuild/route-ok.rs");
-
- test_route_duplicate_unexpected_method(&t);
- test_route_missing_method(&t)
-}
-
-#[rustversion::stable(1.42)]
-fn test_route_missing_method(t: &trybuild::TestCases) {
- t.compile_fail("tests/trybuild/route-missing-method-fail-msrv.rs");
-}
-
-#[rustversion::not(stable(1.42))]
-#[rustversion::not(nightly)]
-fn test_route_missing_method(t: &trybuild::TestCases) {
t.compile_fail("tests/trybuild/route-missing-method-fail.rs");
-}
-
-#[rustversion::nightly]
-fn test_route_missing_method(_t: &trybuild::TestCases) {}
-
-// FIXME: Re-test them on nightly once rust-lang/rust#77993 is fixed.
-#[rustversion::not(nightly)]
-fn test_route_duplicate_unexpected_method(t: &trybuild::TestCases) {
t.compile_fail("tests/trybuild/route-duplicate-method-fail.rs");
t.compile_fail("tests/trybuild/route-unexpected-method-fail.rs");
}
-#[rustversion::nightly]
-fn test_route_duplicate_unexpected_method(_t: &trybuild::TestCases) {}
+// #[rustversion::not(nightly)]
+// fn skip_on_nightly(t: &trybuild::TestCases) {
+//
+// }
+
+// #[rustversion::nightly]
+// fn skip_on_nightly(_t: &trybuild::TestCases) {}
diff --git a/actix-web-codegen/tests/trybuild/route-missing-method-fail-msrv.rs b/actix-web-codegen/tests/trybuild/route-missing-method-fail-msrv.rs
deleted file mode 120000
index 70a5c0e33..000000000
--- a/actix-web-codegen/tests/trybuild/route-missing-method-fail-msrv.rs
+++ /dev/null
@@ -1 +0,0 @@
-route-missing-method-fail.rs
\ No newline at end of file
diff --git a/actix-web-codegen/tests/trybuild/route-missing-method-fail-msrv.stderr b/actix-web-codegen/tests/trybuild/route-missing-method-fail-msrv.stderr
deleted file mode 100644
index d3e2b60ae..000000000
--- a/actix-web-codegen/tests/trybuild/route-missing-method-fail-msrv.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error: The #[route(..)] macro requires at least one `method` attribute
- --> $DIR/route-missing-method-fail-msrv.rs:3:1
- |
-3 | #[route("/")]
- | ^^^^^^^^^^^^^
-
-error[E0425]: cannot find value `index` in this scope
- --> $DIR/route-missing-method-fail-msrv.rs:12:49
- |
-12 | let srv = test::start(|| App::new().service(index));
- | ^^^^^ not found in this scope
diff --git a/awc/README.md b/awc/README.md
index b97d4fa00..972a80140 100644
--- a/awc/README.md
+++ b/awc/README.md
@@ -13,7 +13,7 @@
- [API Documentation](https://docs.rs/awc)
- [Example Project](https://github.com/actix/examples/tree/HEAD/awc_https)
- [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
```rust
diff --git a/docs/graphs/net-only.dot b/docs/graphs/net-only.dot
index 0eebf2a6f..9488f3fe7 100644
--- a/docs/graphs/net-only.dot
+++ b/docs/graphs/net-only.dot
@@ -2,12 +2,10 @@ digraph {
subgraph cluster_net {
label="actix/actix-net";
"actix-codec"
- "actix-connect"
"actix-macros"
"actix-rt"
"actix-server"
"actix-service"
- "actix-testing"
"actix-threadpool"
"actix-tls"
"actix-tracing"
@@ -17,9 +15,7 @@ digraph {
"actix-utils" -> { "actix-service" "actix-rt" "actix-codec" }
"actix-tracing" -> { "actix-service" }
- "actix-tls" -> { "actix-service" "actix-codec" "actix-utils" }
- "actix-testing" -> { "actix-rt" "actix-macros" "actix-server" "actix-service" }
+ "actix-tls" -> { "actix-service" "actix-codec" "actix-utils" "actix-rt" }
"actix-server" -> { "actix-service" "actix-rt" "actix-codec" "actix-utils" }
"actix-rt" -> { "actix-macros" "actix-threadpool" }
- "actix-connect" -> { "actix-service" "actix-codec" "actix-utils" "actix-rt" }
}
diff --git a/docs/graphs/web-focus.dot b/docs/graphs/web-focus.dot
index 17228fe62..55a82bb41 100644
--- a/docs/graphs/web-focus.dot
+++ b/docs/graphs/web-focus.dot
@@ -2,31 +2,29 @@ digraph {
subgraph cluster_web {
label="actix/actix-web"
"awc"
- "web"
- "files"
- "http"
- "multipart"
- "web-actors"
- "codegen"
- "http-test"
+ "actix-web"
+ "actix-files"
+ "actix-http"
+ "actix-multipart"
+ "actix-web-actors"
+ "actix-web-codegen"
+ "actix-http-test"
}
- "web" -> { "codec" "service" "utils" "router" "rt" "server" "testing" "macros" "threadpool" "tls" "codegen" "http" "awc" }
- "awc" -> { "codec" "service" "http" "rt" }
- "web-actors" -> { "actix" "web" "http" "codec" }
- "multipart" -> { "web" "service" "utils" }
- "http" -> { "service" "codec" "connect" "utils" "rt" "threadpool" }
- "http" -> { "actix" "tls" }[color=blue] // optional
- "files" -> { "web" }
- "http-test" -> { "service" "codec" "connect" "utils" "rt" "server" "testing" "awc" }
+ "actix-web" -> { "actix-codec" "actix-service" "actix-utils" "actix-router" "actix-rt" "actix-server" "macros" "threadpool" "actix-tls" "actix-web-codegen" "actix-http" "awc" }
+ "awc" -> { "actix-codec" "actix-service" "actix-http" "actix-rt" }
+ "actix-web-actors" -> { "actix" "actix-web" "actix-http" "actix-codec" }
+ "actix-multipart" -> { "actix-web" "actix-service" "actix-utils" }
+ "actix-http" -> { "actix-service" "actix-codec" "actix-tls" "actix-utils" "actix-rt" "threadpool" }
+ "actix-http" -> { "actix" "actix-tls" }[color=blue] // optional
+ "actix-files" -> { "actix-web" }
+ "actix-http-test" -> { "actix-service" "actix-codec" "actix-tls" "actix-utils" "actix-rt" "actix-server" "awc" }
// net
- "utils" -> { "service" "rt" "codec" }
- "tracing" -> { "service" }
- "tls" -> { "service" "codec" "utils" }
- "testing" -> { "rt" "macros" "server" "service" }
- "server" -> { "service" "rt" "codec" "utils" }
- "rt" -> { "macros" "threadpool" }
- "connect" -> { "service" "codec" "utils" "rt" }
+ "actix-utils" -> { "actix-service" "actix-rt" "actix-codec" }
+ "actix-tracing" -> { "actix-service" }
+ "actix-tls" -> { "actix-service" "actix-codec" "actix-utils" }
+ "actix-server" -> { "actix-service" "actix-rt" "actix-codec" "actix-utils" }
+ "actix-rt" -> { "macros" "threadpool" }
}
diff --git a/src/handler.rs b/src/handler.rs
index 678b9124e..14e8cb40b 100644
--- a/src/handler.rs
+++ b/src/handler.rs
@@ -199,14 +199,14 @@ macro_rules! factory_tuple ({ $(($n:tt, $T:ident)),+} => {
mod m {
use super::*;
-factory_tuple!((0, A));
-factory_tuple!((0, A), (1, B));
-factory_tuple!((0, A), (1, B), (2, C));
-factory_tuple!((0, A), (1, B), (2, C), (3, D));
-factory_tuple!((0, A), (1, B), (2, C), (3, D), (4, E));
-factory_tuple!((0, A), (1, B), (2, C), (3, D), (4, E), (5, F));
-factory_tuple!((0, A), (1, B), (2, C), (3, D), (4, E), (5, F), (6, G));
-factory_tuple!((0, A), (1, B), (2, C), (3, D), (4, E), (5, F), (6, G), (7, H));
-factory_tuple!((0, A), (1, B), (2, C), (3, D), (4, E), (5, F), (6, G), (7, H), (8, I));
-factory_tuple!((0, A), (1, B), (2, C), (3, D), (4, E), (5, F), (6, G), (7, H), (8, I), (9, J));
+ factory_tuple!((0, A));
+ factory_tuple!((0, A), (1, B));
+ factory_tuple!((0, A), (1, B), (2, C));
+ factory_tuple!((0, A), (1, B), (2, C), (3, D));
+ factory_tuple!((0, A), (1, B), (2, C), (3, D), (4, E));
+ factory_tuple!((0, A), (1, B), (2, C), (3, D), (4, E), (5, F));
+ factory_tuple!((0, A), (1, B), (2, C), (3, D), (4, E), (5, F), (6, G));
+ factory_tuple!((0, A), (1, B), (2, C), (3, D), (4, E), (5, F), (6, G), (7, H));
+ factory_tuple!((0, A), (1, B), (2, C), (3, D), (4, E), (5, F), (6, G), (7, H), (8, I));
+ factory_tuple!((0, A), (1, B), (2, C), (3, D), (4, E), (5, F), (6, G), (7, H), (8, I), (9, J));
}
diff --git a/src/lib.rs b/src/lib.rs
index 8246c8286..88eae44bf 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -56,7 +56,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+
//!
//! ## Crate Features
//!
@@ -65,7 +65,7 @@
//! * `rustls` - HTTPS support via `rustls` crate, supports `HTTP/2`
//! * `secure-cookies` - secure cookies support
-#![deny(rust_2018_idioms)]
+#![deny(rust_2018_idioms, nonstandard_style)]
#![allow(clippy::needless_doctest_main, clippy::type_complexity)]
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
diff --git a/src/middleware/errhandlers.rs b/src/middleware/errhandlers.rs
index 9366a33bf..9e78bb7d0 100644
--- a/src/middleware/errhandlers.rs
+++ b/src/middleware/errhandlers.rs
@@ -177,6 +177,7 @@ mod tests {
assert_eq!(resp.headers().get(CONTENT_TYPE).unwrap(), "0001");
}
+ #[allow(clippy::unnecessary_wraps)]
fn render_500_async(
mut res: ServiceResponse,
) -> Result> {
diff --git a/tests/test_httpserver.rs b/tests/test_httpserver.rs
index 54510b7d4..0f1c56a84 100644
--- a/tests/test_httpserver.rs
+++ b/tests/test_httpserver.rs
@@ -66,6 +66,7 @@ async fn test_start() {
let _ = sys.stop();
}
+#[allow(clippy::unnecessary_wraps)]
#[cfg(feature = "openssl")]
fn ssl_acceptor() -> std::io::Result {
use open_ssl::ssl::{SslAcceptor, SslFiletype, SslMethod};