mirror of
https://github.com/fafhrd91/actix-web
synced 2025-07-03 01:34:32 +02:00
Compare commits
30 Commits
web-v4.1.0
...
normalize-
Author | SHA1 | Date | |
---|---|---|---|
d54c26ad30 | |||
c0d5d7bdb5 | |||
40eab1f091 | |||
75517cce82 | |||
9b51624b27 | |||
8e2ae8cd40 | |||
9a2f8450e0 | |||
23ef51609e | |||
f7d629a61a | |||
e0845d9ad9 | |||
2f79daec16 | |||
f3f41a0cc7 | |||
987067698b | |||
b62f1b4ef7 | |||
df5257c373 | |||
226ea696ce | |||
e524fc86ea | |||
7e990e423f | |||
8f9a12ed5d | |||
c6eba2da9b | |||
06c7945801 | |||
0dba6310c6 | |||
f7d7d92984 | |||
3d6ea7fe9b | |||
8dbf7da89f | |||
de92b3be2e | |||
5d0e8138ee | |||
6b7196225e | |||
265fa0d050 | |||
062127a210 |
40
.github/workflows/ci-post-merge.yml
vendored
40
.github/workflows/ci-post-merge.yml
vendored
@ -23,6 +23,7 @@ jobs:
|
||||
CI: 1
|
||||
CARGO_INCREMENTAL: 0
|
||||
VCPKGRS_DYNAMIC: 1
|
||||
CARGO_UNSTABLE_SPARSE_REGISTRY: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@ -44,18 +45,15 @@ jobs:
|
||||
profile: minimal
|
||||
override: true
|
||||
|
||||
- name: Install cargo-hack
|
||||
uses: taiki-e/install-action@cargo-hack
|
||||
|
||||
- name: Generate Cargo.lock
|
||||
uses: actions-rs/cargo@v1
|
||||
with: { command: generate-lockfile }
|
||||
- name: Cache Dependencies
|
||||
uses: Swatinem/rust-cache@v1.2.0
|
||||
|
||||
- name: Install cargo-hack
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: install
|
||||
args: cargo-hack
|
||||
|
||||
- name: check minimal
|
||||
uses: actions-rs/cargo@v1
|
||||
with: { command: ci-check-min }
|
||||
@ -80,12 +78,17 @@ jobs:
|
||||
|
||||
- name: Clear the cargo caches
|
||||
run: |
|
||||
cargo install cargo-cache --version 0.6.3 --no-default-features --features ci-autoclean
|
||||
cargo install cargo-cache --version 0.8.2 --no-default-features --features ci-autoclean
|
||||
cargo-cache
|
||||
|
||||
ci_feature_powerset_check:
|
||||
name: Verify Feature Combinations
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
CI: 1
|
||||
CARGO_INCREMENTAL: 0
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
@ -96,18 +99,15 @@ jobs:
|
||||
profile: minimal
|
||||
override: true
|
||||
|
||||
- name: Install cargo-hack
|
||||
uses: taiki-e/install-action@cargo-hack
|
||||
|
||||
- name: Generate Cargo.lock
|
||||
uses: actions-rs/cargo@v1
|
||||
with: { command: generate-lockfile }
|
||||
- name: Cache Dependencies
|
||||
uses: Swatinem/rust-cache@v1.2.0
|
||||
|
||||
- name: Install cargo-hack
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: install
|
||||
args: cargo-hack
|
||||
|
||||
- name: check feature combinations
|
||||
uses: actions-rs/cargo@v1
|
||||
with: { command: ci-check-all-feature-powerset }
|
||||
@ -119,6 +119,11 @@ jobs:
|
||||
nextest:
|
||||
name: nextest
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
CI: 1
|
||||
CARGO_INCREMENTAL: 0
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
@ -129,18 +134,15 @@ jobs:
|
||||
profile: minimal
|
||||
override: true
|
||||
|
||||
- name: Install nextest
|
||||
uses: taiki-e/install-action@nextest
|
||||
|
||||
- name: Generate Cargo.lock
|
||||
uses: actions-rs/cargo@v1
|
||||
with: { command: generate-lockfile }
|
||||
- name: Cache Dependencies
|
||||
uses: Swatinem/rust-cache@v1.3.0
|
||||
|
||||
- name: Install cargo-nextest
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: install
|
||||
args: cargo-nextest
|
||||
|
||||
- name: Test with cargo-nextest
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
|
20
.github/workflows/ci.yml
vendored
20
.github/workflows/ci.yml
vendored
@ -16,7 +16,7 @@ jobs:
|
||||
- { name: macOS, os: macos-latest, triple: x86_64-apple-darwin }
|
||||
- { name: Windows, os: windows-2022, triple: x86_64-pc-windows-msvc }
|
||||
version:
|
||||
- 1.56.0 # MSRV
|
||||
- 1.57.0 # MSRV
|
||||
- stable
|
||||
|
||||
name: ${{ matrix.target.name }} / ${{ matrix.version }}
|
||||
@ -47,18 +47,22 @@ jobs:
|
||||
profile: minimal
|
||||
override: true
|
||||
|
||||
- name: Install cargo-hack
|
||||
uses: taiki-e/install-action@cargo-hack
|
||||
|
||||
- name: workaround MSRV issues
|
||||
if: matrix.version != 'stable'
|
||||
run: |
|
||||
cargo install cargo-edit --version=0.8.0
|
||||
cargo add const-str@0.3 --dev -p=actix-web
|
||||
cargo add const-str@0.3 --dev -p=awc
|
||||
|
||||
- name: Generate Cargo.lock
|
||||
uses: actions-rs/cargo@v1
|
||||
with: { command: generate-lockfile }
|
||||
- name: Cache Dependencies
|
||||
uses: Swatinem/rust-cache@v1.2.0
|
||||
|
||||
- name: Install cargo-hack
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: install
|
||||
args: cargo-hack
|
||||
|
||||
- name: check minimal
|
||||
uses: actions-rs/cargo@v1
|
||||
with: { command: ci-check-min }
|
||||
@ -83,7 +87,7 @@ jobs:
|
||||
|
||||
- name: Clear the cargo caches
|
||||
run: |
|
||||
cargo install cargo-cache --version 0.6.3 --no-default-features --features ci-autoclean
|
||||
cargo install cargo-cache --version 0.8.2 --no-default-features --features ci-autoclean
|
||||
cargo-cache
|
||||
|
||||
io-uring:
|
||||
|
@ -1,6 +1,7 @@
|
||||
# Changes
|
||||
|
||||
## Unreleased - 2021-xx-xx
|
||||
## Unreleased - 2022-xx-xx
|
||||
- Minimum supported Rust version (MSRV) is now 1.57 due to transitive `time` dependency.
|
||||
|
||||
|
||||
## 0.6.1 - 2022-06-11
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
[](https://crates.io/crates/actix-files)
|
||||
[](https://docs.rs/actix-files/0.6.1)
|
||||

|
||||

|
||||

|
||||
<br />
|
||||
[](https://deps.rs/crate/actix-files/0.6.1)
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Changes
|
||||
|
||||
## Unreleased - 2021-xx-xx
|
||||
- Minimum supported Rust version (MSRV) is now 1.56 due to transitive `hashbrown` dependency.
|
||||
## Unreleased - 2022-xx-xx
|
||||
- Minimum supported Rust version (MSRV) is now 1.57 due to transitive `time` dependency.
|
||||
|
||||
|
||||
## 3.0.0-beta.13 - 2022-02-16
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
[](https://crates.io/crates/actix-http-test)
|
||||
[](https://docs.rs/actix-http-test/3.0.0-beta.13)
|
||||

|
||||

|
||||

|
||||
<br>
|
||||
[](https://deps.rs/crate/actix-http-test/3.0.0-beta.13)
|
||||
|
@ -1,6 +1,25 @@
|
||||
# Changes
|
||||
|
||||
## Unreleased - 2021-xx-xx
|
||||
## Unreleased - 2022-xx-xx
|
||||
|
||||
|
||||
## 3.2.1 - 2022-07-02
|
||||
### Fixed
|
||||
- Fix parsing ambiguity in Transfer-Encoding and Content-Length headers for HTTP/1.0 requests. [#2794]
|
||||
|
||||
[#2794]: https://github.com/actix/actix-web/pull/2794
|
||||
|
||||
|
||||
## 3.2.0 - 2022-06-30
|
||||
### Changed
|
||||
- Minimum supported Rust version (MSRV) is now 1.57 due to transitive `time` dependency.
|
||||
|
||||
### Fixed
|
||||
- Websocket parser no longer throws endless overflow errors after receiving an oversized frame. [#2790]
|
||||
- Retain previously set Vary headers when using compression encoder. [#2798]
|
||||
|
||||
[#2790]: https://github.com/actix/actix-web/pull/2790
|
||||
[#2798]: https://github.com/actix/actix-web/pull/2798
|
||||
|
||||
|
||||
## 3.1.0 - 2022-06-11
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "actix-http"
|
||||
version = "3.1.0"
|
||||
version = "3.2.1"
|
||||
authors = [
|
||||
"Nikolay Kim <fafhrd91@gmail.com>",
|
||||
"Rob Ede <robjtede@icloud.com>",
|
||||
@ -100,7 +100,7 @@ zstd = { version = "0.11", optional = true }
|
||||
actix-http-test = { version = "3.0.0-beta.13", features = ["openssl"] }
|
||||
actix-server = "2"
|
||||
actix-tls = { version = "3", features = ["openssl"] }
|
||||
actix-web = { git = "https://github.com/actix/actix-web", rev = "43671ae4aaf2c20150fd1e5ca54055eb5d114273" }
|
||||
actix-web = "4"
|
||||
|
||||
async-stream = "0.3"
|
||||
criterion = { version = "0.3", features = ["html_reports"] }
|
||||
@ -108,10 +108,10 @@ env_logger = "0.9"
|
||||
futures-util = { version = "0.3.7", default-features = false, features = ["alloc"] }
|
||||
memchr = "2.4"
|
||||
once_cell = "1.9"
|
||||
rcgen = "0.8"
|
||||
rcgen = "0.9"
|
||||
regex = "1.3"
|
||||
rustversion = "1"
|
||||
rustls-pemfile = "0.2"
|
||||
rustls-pemfile = "1"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
static_assertions = "1"
|
||||
|
@ -3,11 +3,11 @@
|
||||
> HTTP primitives for the Actix ecosystem.
|
||||
|
||||
[](https://crates.io/crates/actix-http)
|
||||
[](https://docs.rs/actix-http/3.1.0)
|
||||

|
||||
[](https://docs.rs/actix-http/3.2.1)
|
||||

|
||||

|
||||
<br />
|
||||
[](https://deps.rs/crate/actix-http/3.1.0)
|
||||
[](https://deps.rs/crate/actix-http/3.2.1)
|
||||
[](https://crates.io/crates/actix-http)
|
||||
[](https://discord.gg/NWpN5mmg3x)
|
||||
|
||||
|
@ -481,6 +481,7 @@ mod tests {
|
||||
assert_poll_next_none!(pl);
|
||||
}
|
||||
|
||||
#[allow(clippy::let_unit_value)]
|
||||
#[actix_rt::test]
|
||||
async fn test_unit() {
|
||||
let pl = ();
|
||||
|
@ -257,7 +257,7 @@ fn update_head(encoding: ContentEncoding, head: &mut ResponseHead) {
|
||||
head.headers_mut()
|
||||
.insert(header::CONTENT_ENCODING, encoding.to_header_value());
|
||||
head.headers_mut()
|
||||
.insert(header::VARY, HeaderValue::from_static("accept-encoding"));
|
||||
.append(header::VARY, HeaderValue::from_static("accept-encoding"));
|
||||
|
||||
head.no_chunking(false);
|
||||
}
|
||||
|
@ -46,6 +46,23 @@ pub(crate) enum PayloadLength {
|
||||
None,
|
||||
}
|
||||
|
||||
impl PayloadLength {
|
||||
/// Returns true if variant is `None`.
|
||||
fn is_none(&self) -> bool {
|
||||
matches!(self, Self::None)
|
||||
}
|
||||
|
||||
/// Returns true if variant is represents zero-length (not none) payload.
|
||||
fn is_zero(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
PayloadLength::Payload(PayloadType::Payload(PayloadDecoder {
|
||||
kind: Kind::Length(0)
|
||||
}))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) trait MessageType: Sized {
|
||||
fn set_connection_type(&mut self, conn_type: Option<ConnectionType>);
|
||||
|
||||
@ -59,6 +76,7 @@ pub(crate) trait MessageType: Sized {
|
||||
&mut self,
|
||||
slice: &Bytes,
|
||||
raw_headers: &[HeaderIndex],
|
||||
version: Version,
|
||||
) -> Result<PayloadLength, ParseError> {
|
||||
let mut ka = None;
|
||||
let mut has_upgrade_websocket = false;
|
||||
@ -87,21 +105,23 @@ pub(crate) trait MessageType: Sized {
|
||||
return Err(ParseError::Header);
|
||||
}
|
||||
|
||||
header::CONTENT_LENGTH => match value.to_str() {
|
||||
Ok(s) if s.trim().starts_with('+') => {
|
||||
debug!("illegal Content-Length: {:?}", s);
|
||||
header::CONTENT_LENGTH => match value.to_str().map(str::trim) {
|
||||
Ok(val) if val.starts_with('+') => {
|
||||
debug!("illegal Content-Length: {:?}", val);
|
||||
return Err(ParseError::Header);
|
||||
}
|
||||
Ok(s) => {
|
||||
if let Ok(len) = s.parse::<u64>() {
|
||||
if len != 0 {
|
||||
content_length = Some(len);
|
||||
}
|
||||
|
||||
Ok(val) => {
|
||||
if let Ok(len) = val.parse::<u64>() {
|
||||
// accept 0 lengths here and remove them in `decode` after all
|
||||
// headers have been processed to prevent request smuggling issues
|
||||
content_length = Some(len);
|
||||
} else {
|
||||
debug!("illegal Content-Length: {:?}", s);
|
||||
debug!("illegal Content-Length: {:?}", val);
|
||||
return Err(ParseError::Header);
|
||||
}
|
||||
}
|
||||
|
||||
Err(_) => {
|
||||
debug!("illegal Content-Length: {:?}", value);
|
||||
return Err(ParseError::Header);
|
||||
@ -114,22 +134,23 @@ pub(crate) trait MessageType: Sized {
|
||||
return Err(ParseError::Header);
|
||||
}
|
||||
|
||||
header::TRANSFER_ENCODING => {
|
||||
header::TRANSFER_ENCODING if version == Version::HTTP_11 => {
|
||||
seen_te = true;
|
||||
|
||||
if let Ok(s) = value.to_str().map(str::trim) {
|
||||
if s.eq_ignore_ascii_case("chunked") {
|
||||
if let Ok(val) = value.to_str().map(str::trim) {
|
||||
if val.eq_ignore_ascii_case("chunked") {
|
||||
chunked = true;
|
||||
} else if s.eq_ignore_ascii_case("identity") {
|
||||
} else if val.eq_ignore_ascii_case("identity") {
|
||||
// allow silently since multiple TE headers are already checked
|
||||
} else {
|
||||
debug!("illegal Transfer-Encoding: {:?}", s);
|
||||
debug!("illegal Transfer-Encoding: {:?}", val);
|
||||
return Err(ParseError::Header);
|
||||
}
|
||||
} else {
|
||||
return Err(ParseError::Header);
|
||||
}
|
||||
}
|
||||
|
||||
// connection keep-alive state
|
||||
header::CONNECTION => {
|
||||
ka = if let Ok(conn) = value.to_str().map(str::trim) {
|
||||
@ -146,6 +167,7 @@ pub(crate) trait MessageType: Sized {
|
||||
None
|
||||
};
|
||||
}
|
||||
|
||||
header::UPGRADE => {
|
||||
if let Ok(val) = value.to_str().map(str::trim) {
|
||||
if val.eq_ignore_ascii_case("websocket") {
|
||||
@ -153,19 +175,23 @@ pub(crate) trait MessageType: Sized {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
header::EXPECT => {
|
||||
let bytes = value.as_bytes();
|
||||
if bytes.len() >= 4 && &bytes[0..4] == b"100-" {
|
||||
expect = true;
|
||||
}
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
|
||||
headers.append(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
self.set_connection_type(ka);
|
||||
|
||||
if expect {
|
||||
self.set_expect()
|
||||
}
|
||||
@ -249,7 +275,22 @@ impl MessageType for Request {
|
||||
let mut msg = Request::new();
|
||||
|
||||
// convert headers
|
||||
let length = msg.set_headers(&src.split_to(len).freeze(), &headers[..h_len])?;
|
||||
let mut length =
|
||||
msg.set_headers(&src.split_to(len).freeze(), &headers[..h_len], ver)?;
|
||||
|
||||
// disallow HTTP/1.0 POST requests that do not contain a Content-Length headers
|
||||
// see https://datatracker.ietf.org/doc/html/rfc1945#section-7.2.2
|
||||
if ver == Version::HTTP_10 && method == Method::POST && length.is_none() {
|
||||
debug!("no Content-Length specified for HTTP/1.0 POST request");
|
||||
return Err(ParseError::Header);
|
||||
}
|
||||
|
||||
// Remove CL value if 0 now that all headers and HTTP/1.0 special cases are processed.
|
||||
// Protects against some request smuggling attacks.
|
||||
// See https://github.com/actix/actix-web/issues/2767.
|
||||
if length.is_zero() {
|
||||
length = PayloadLength::None;
|
||||
}
|
||||
|
||||
// payload decoder
|
||||
let decoder = match length {
|
||||
@ -337,7 +378,15 @@ impl MessageType for ResponseHead {
|
||||
msg.version = ver;
|
||||
|
||||
// convert headers
|
||||
let length = msg.set_headers(&src.split_to(len).freeze(), &headers[..h_len])?;
|
||||
let mut length =
|
||||
msg.set_headers(&src.split_to(len).freeze(), &headers[..h_len], ver)?;
|
||||
|
||||
// Remove CL value if 0 now that all headers and HTTP/1.0 special cases are processed.
|
||||
// Protects against some request smuggling attacks.
|
||||
// See https://github.com/actix/actix-web/issues/2767.
|
||||
if length.is_zero() {
|
||||
length = PayloadLength::None;
|
||||
}
|
||||
|
||||
// message payload
|
||||
let decoder = if let PayloadLength::Payload(pl) = length {
|
||||
@ -606,14 +655,100 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_post() {
|
||||
let mut buf = BytesMut::from("POST /test2 HTTP/1.0\r\n\r\n");
|
||||
fn parse_h09_reject() {
|
||||
let mut buf = BytesMut::from(
|
||||
"GET /test1 HTTP/0.9\r\n\
|
||||
\r\n",
|
||||
);
|
||||
|
||||
let mut reader = MessageDecoder::<Request>::default();
|
||||
reader.decode(&mut buf).unwrap_err();
|
||||
|
||||
let mut buf = BytesMut::from(
|
||||
"POST /test2 HTTP/0.9\r\n\
|
||||
Content-Length: 3\r\n\
|
||||
\r\n
|
||||
abc",
|
||||
);
|
||||
|
||||
let mut reader = MessageDecoder::<Request>::default();
|
||||
reader.decode(&mut buf).unwrap_err();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_h10_get() {
|
||||
let mut buf = BytesMut::from(
|
||||
"GET /test1 HTTP/1.0\r\n\
|
||||
\r\n",
|
||||
);
|
||||
|
||||
let mut reader = MessageDecoder::<Request>::default();
|
||||
let (req, _) = reader.decode(&mut buf).unwrap().unwrap();
|
||||
assert_eq!(req.version(), Version::HTTP_10);
|
||||
assert_eq!(*req.method(), Method::GET);
|
||||
assert_eq!(req.path(), "/test1");
|
||||
|
||||
let mut buf = BytesMut::from(
|
||||
"GET /test2 HTTP/1.0\r\n\
|
||||
Content-Length: 0\r\n\
|
||||
\r\n",
|
||||
);
|
||||
|
||||
let mut reader = MessageDecoder::<Request>::default();
|
||||
let (req, _) = reader.decode(&mut buf).unwrap().unwrap();
|
||||
assert_eq!(req.version(), Version::HTTP_10);
|
||||
assert_eq!(*req.method(), Method::GET);
|
||||
assert_eq!(req.path(), "/test2");
|
||||
|
||||
let mut buf = BytesMut::from(
|
||||
"GET /test3 HTTP/1.0\r\n\
|
||||
Content-Length: 3\r\n\
|
||||
\r\n
|
||||
abc",
|
||||
);
|
||||
|
||||
let mut reader = MessageDecoder::<Request>::default();
|
||||
let (req, _) = reader.decode(&mut buf).unwrap().unwrap();
|
||||
assert_eq!(req.version(), Version::HTTP_10);
|
||||
assert_eq!(*req.method(), Method::GET);
|
||||
assert_eq!(req.path(), "/test3");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_h10_post() {
|
||||
let mut buf = BytesMut::from(
|
||||
"POST /test1 HTTP/1.0\r\n\
|
||||
Content-Length: 3\r\n\
|
||||
\r\n\
|
||||
abc",
|
||||
);
|
||||
|
||||
let mut reader = MessageDecoder::<Request>::default();
|
||||
let (req, _) = reader.decode(&mut buf).unwrap().unwrap();
|
||||
assert_eq!(req.version(), Version::HTTP_10);
|
||||
assert_eq!(*req.method(), Method::POST);
|
||||
assert_eq!(req.path(), "/test1");
|
||||
|
||||
let mut buf = BytesMut::from(
|
||||
"POST /test2 HTTP/1.0\r\n\
|
||||
Content-Length: 0\r\n\
|
||||
\r\n",
|
||||
);
|
||||
|
||||
let mut reader = MessageDecoder::<Request>::default();
|
||||
let (req, _) = reader.decode(&mut buf).unwrap().unwrap();
|
||||
assert_eq!(req.version(), Version::HTTP_10);
|
||||
assert_eq!(*req.method(), Method::POST);
|
||||
assert_eq!(req.path(), "/test2");
|
||||
|
||||
let mut buf = BytesMut::from(
|
||||
"POST /test3 HTTP/1.0\r\n\
|
||||
\r\n",
|
||||
);
|
||||
|
||||
let mut reader = MessageDecoder::<Request>::default();
|
||||
let err = reader.decode(&mut buf).unwrap_err();
|
||||
assert!(err.to_string().contains("Header"))
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -709,121 +844,98 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_conn_default_1_0() {
|
||||
let mut buf = BytesMut::from("GET /test HTTP/1.0\r\n\r\n");
|
||||
let req = parse_ready!(&mut buf);
|
||||
|
||||
let req = parse_ready!(&mut BytesMut::from("GET /test HTTP/1.0\r\n\r\n"));
|
||||
assert_eq!(req.head().connection_type(), ConnectionType::Close);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_conn_default_1_1() {
|
||||
let mut buf = BytesMut::from("GET /test HTTP/1.1\r\n\r\n");
|
||||
let req = parse_ready!(&mut buf);
|
||||
|
||||
let req = parse_ready!(&mut BytesMut::from("GET /test HTTP/1.1\r\n\r\n"));
|
||||
assert_eq!(req.head().connection_type(), ConnectionType::KeepAlive);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_conn_close() {
|
||||
let mut buf = BytesMut::from(
|
||||
let req = parse_ready!(&mut BytesMut::from(
|
||||
"GET /test HTTP/1.1\r\n\
|
||||
connection: close\r\n\r\n",
|
||||
);
|
||||
let req = parse_ready!(&mut buf);
|
||||
|
||||
));
|
||||
assert_eq!(req.head().connection_type(), ConnectionType::Close);
|
||||
|
||||
let mut buf = BytesMut::from(
|
||||
let req = parse_ready!(&mut BytesMut::from(
|
||||
"GET /test HTTP/1.1\r\n\
|
||||
connection: Close\r\n\r\n",
|
||||
);
|
||||
let req = parse_ready!(&mut buf);
|
||||
|
||||
));
|
||||
assert_eq!(req.head().connection_type(), ConnectionType::Close);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_conn_close_1_0() {
|
||||
let mut buf = BytesMut::from(
|
||||
let req = parse_ready!(&mut BytesMut::from(
|
||||
"GET /test HTTP/1.0\r\n\
|
||||
connection: close\r\n\r\n",
|
||||
);
|
||||
|
||||
let req = parse_ready!(&mut buf);
|
||||
|
||||
));
|
||||
assert_eq!(req.head().connection_type(), ConnectionType::Close);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_conn_keep_alive_1_0() {
|
||||
let mut buf = BytesMut::from(
|
||||
let req = parse_ready!(&mut BytesMut::from(
|
||||
"GET /test HTTP/1.0\r\n\
|
||||
connection: keep-alive\r\n\r\n",
|
||||
);
|
||||
let req = parse_ready!(&mut buf);
|
||||
|
||||
));
|
||||
assert_eq!(req.head().connection_type(), ConnectionType::KeepAlive);
|
||||
|
||||
let mut buf = BytesMut::from(
|
||||
let req = parse_ready!(&mut BytesMut::from(
|
||||
"GET /test HTTP/1.0\r\n\
|
||||
connection: Keep-Alive\r\n\r\n",
|
||||
);
|
||||
let req = parse_ready!(&mut buf);
|
||||
|
||||
));
|
||||
assert_eq!(req.head().connection_type(), ConnectionType::KeepAlive);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_conn_keep_alive_1_1() {
|
||||
let mut buf = BytesMut::from(
|
||||
let req = parse_ready!(&mut BytesMut::from(
|
||||
"GET /test HTTP/1.1\r\n\
|
||||
connection: keep-alive\r\n\r\n",
|
||||
);
|
||||
let req = parse_ready!(&mut buf);
|
||||
|
||||
));
|
||||
assert_eq!(req.head().connection_type(), ConnectionType::KeepAlive);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_conn_other_1_0() {
|
||||
let mut buf = BytesMut::from(
|
||||
let req = parse_ready!(&mut BytesMut::from(
|
||||
"GET /test HTTP/1.0\r\n\
|
||||
connection: other\r\n\r\n",
|
||||
);
|
||||
let req = parse_ready!(&mut buf);
|
||||
|
||||
));
|
||||
assert_eq!(req.head().connection_type(), ConnectionType::Close);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_conn_other_1_1() {
|
||||
let mut buf = BytesMut::from(
|
||||
let req = parse_ready!(&mut BytesMut::from(
|
||||
"GET /test HTTP/1.1\r\n\
|
||||
connection: other\r\n\r\n",
|
||||
);
|
||||
let req = parse_ready!(&mut buf);
|
||||
|
||||
));
|
||||
assert_eq!(req.head().connection_type(), ConnectionType::KeepAlive);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_conn_upgrade() {
|
||||
let mut buf = BytesMut::from(
|
||||
let req = parse_ready!(&mut BytesMut::from(
|
||||
"GET /test HTTP/1.1\r\n\
|
||||
upgrade: websockets\r\n\
|
||||
connection: upgrade\r\n\r\n",
|
||||
);
|
||||
let req = parse_ready!(&mut buf);
|
||||
));
|
||||
|
||||
assert!(req.upgrade());
|
||||
assert_eq!(req.head().connection_type(), ConnectionType::Upgrade);
|
||||
|
||||
let mut buf = BytesMut::from(
|
||||
let req = parse_ready!(&mut BytesMut::from(
|
||||
"GET /test HTTP/1.1\r\n\
|
||||
upgrade: Websockets\r\n\
|
||||
connection: Upgrade\r\n\r\n",
|
||||
);
|
||||
let req = parse_ready!(&mut buf);
|
||||
));
|
||||
|
||||
assert!(req.upgrade());
|
||||
assert_eq!(req.head().connection_type(), ConnectionType::Upgrade);
|
||||
@ -831,59 +943,62 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_conn_upgrade_connect_method() {
|
||||
let mut buf = BytesMut::from(
|
||||
let req = parse_ready!(&mut BytesMut::from(
|
||||
"CONNECT /test HTTP/1.1\r\n\
|
||||
content-type: text/plain\r\n\r\n",
|
||||
);
|
||||
let req = parse_ready!(&mut buf);
|
||||
));
|
||||
|
||||
assert!(req.upgrade());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_headers_content_length_err_1() {
|
||||
let mut buf = BytesMut::from(
|
||||
fn test_headers_bad_content_length() {
|
||||
// string CL
|
||||
expect_parse_err!(&mut BytesMut::from(
|
||||
"GET /test HTTP/1.1\r\n\
|
||||
content-length: line\r\n\r\n",
|
||||
);
|
||||
));
|
||||
|
||||
expect_parse_err!(&mut buf)
|
||||
// negative CL
|
||||
expect_parse_err!(&mut BytesMut::from(
|
||||
"GET /test HTTP/1.1\r\n\
|
||||
content-length: -1\r\n\r\n",
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_headers_content_length_err_2() {
|
||||
fn octal_ish_cl_parsed_as_decimal() {
|
||||
let mut buf = BytesMut::from(
|
||||
"GET /test HTTP/1.1\r\n\
|
||||
content-length: -1\r\n\r\n",
|
||||
"POST /test HTTP/1.1\r\n\
|
||||
content-length: 011\r\n\r\n",
|
||||
);
|
||||
|
||||
expect_parse_err!(&mut buf);
|
||||
let mut reader = MessageDecoder::<Request>::default();
|
||||
let (_req, pl) = reader.decode(&mut buf).unwrap().unwrap();
|
||||
assert!(matches!(
|
||||
pl,
|
||||
PayloadType::Payload(pl) if pl == PayloadDecoder::length(11)
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_invalid_header() {
|
||||
let mut buf = BytesMut::from(
|
||||
expect_parse_err!(&mut BytesMut::from(
|
||||
"GET /test HTTP/1.1\r\n\
|
||||
test line\r\n\r\n",
|
||||
);
|
||||
|
||||
expect_parse_err!(&mut buf);
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_invalid_name() {
|
||||
let mut buf = BytesMut::from(
|
||||
expect_parse_err!(&mut BytesMut::from(
|
||||
"GET /test HTTP/1.1\r\n\
|
||||
test[]: line\r\n\r\n",
|
||||
);
|
||||
|
||||
expect_parse_err!(&mut buf);
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_http_request_bad_status_line() {
|
||||
let mut buf = BytesMut::from("getpath \r\n\r\n");
|
||||
expect_parse_err!(&mut buf);
|
||||
expect_parse_err!(&mut BytesMut::from("getpath \r\n\r\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -923,11 +1038,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_http_request_parser_utf8() {
|
||||
let mut buf = BytesMut::from(
|
||||
let req = parse_ready!(&mut BytesMut::from(
|
||||
"GET /test HTTP/1.1\r\n\
|
||||
x-test: тест\r\n\r\n",
|
||||
);
|
||||
let req = parse_ready!(&mut buf);
|
||||
));
|
||||
|
||||
assert_eq!(
|
||||
req.headers().get("x-test").unwrap().as_bytes(),
|
||||
@ -937,24 +1051,18 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_http_request_parser_two_slashes() {
|
||||
let mut buf = BytesMut::from("GET //path HTTP/1.1\r\n\r\n");
|
||||
let req = parse_ready!(&mut buf);
|
||||
|
||||
let req = parse_ready!(&mut BytesMut::from("GET //path HTTP/1.1\r\n\r\n"));
|
||||
assert_eq!(req.path(), "//path");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_http_request_parser_bad_method() {
|
||||
let mut buf = BytesMut::from("!12%()+=~$ /get HTTP/1.1\r\n\r\n");
|
||||
|
||||
expect_parse_err!(&mut buf);
|
||||
expect_parse_err!(&mut BytesMut::from("!12%()+=~$ /get HTTP/1.1\r\n\r\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_http_request_parser_bad_version() {
|
||||
let mut buf = BytesMut::from("GET //get HT/11\r\n\r\n");
|
||||
|
||||
expect_parse_err!(&mut buf);
|
||||
expect_parse_err!(&mut BytesMut::from("GET //get HT/11\r\n\r\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -971,29 +1079,66 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn hrs_multiple_content_length() {
|
||||
let mut buf = BytesMut::from(
|
||||
expect_parse_err!(&mut BytesMut::from(
|
||||
"GET / HTTP/1.1\r\n\
|
||||
Host: example.com\r\n\
|
||||
Content-Length: 4\r\n\
|
||||
Content-Length: 2\r\n\
|
||||
\r\n\
|
||||
abcd",
|
||||
);
|
||||
));
|
||||
|
||||
expect_parse_err!(&mut buf);
|
||||
expect_parse_err!(&mut BytesMut::from(
|
||||
"GET / HTTP/1.1\r\n\
|
||||
Host: example.com\r\n\
|
||||
Content-Length: 0\r\n\
|
||||
Content-Length: 2\r\n\
|
||||
\r\n\
|
||||
ab",
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hrs_content_length_plus() {
|
||||
let mut buf = BytesMut::from(
|
||||
expect_parse_err!(&mut BytesMut::from(
|
||||
"GET / HTTP/1.1\r\n\
|
||||
Host: example.com\r\n\
|
||||
Content-Length: +3\r\n\
|
||||
\r\n\
|
||||
000",
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hrs_te_http10() {
|
||||
// in HTTP/1.0 transfer encoding is ignored and must therefore contain a CL header
|
||||
|
||||
expect_parse_err!(&mut BytesMut::from(
|
||||
"POST / HTTP/1.0\r\n\
|
||||
Host: example.com\r\n\
|
||||
Transfer-Encoding: chunked\r\n\
|
||||
\r\n\
|
||||
3\r\n\
|
||||
aaa\r\n\
|
||||
0\r\n\
|
||||
",
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hrs_cl_and_te_http10() {
|
||||
// in HTTP/1.0 transfer encoding is simply ignored so it's fine to have both
|
||||
|
||||
let mut buf = BytesMut::from(
|
||||
"GET / HTTP/1.0\r\n\
|
||||
Host: example.com\r\n\
|
||||
Content-Length: 3\r\n\
|
||||
Transfer-Encoding: chunked\r\n\
|
||||
\r\n\
|
||||
000",
|
||||
);
|
||||
|
||||
expect_parse_err!(&mut buf);
|
||||
parse_ready!(&mut buf);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -25,6 +25,7 @@
|
||||
)]
|
||||
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
|
||||
pub use ::http::{uri, uri::Uri};
|
||||
pub use ::http::{Method, StatusCode, Version};
|
||||
@ -69,6 +70,8 @@ pub use self::payload::{BoxedPayloadStream, Payload, PayloadStream};
|
||||
pub use self::requests::{Request, RequestHead, RequestHeadType};
|
||||
pub use self::responses::{Response, ResponseBuilder, ResponseHead};
|
||||
pub use self::service::HttpService;
|
||||
#[cfg(any(feature = "openssl", feature = "rustls"))]
|
||||
pub use self::service::TlsAcceptorConfig;
|
||||
|
||||
/// A major HTTP protocol version.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||
|
@ -237,7 +237,7 @@ mod tests {
|
||||
.await;
|
||||
|
||||
let mut stream = net::TcpStream::connect(srv.addr()).unwrap();
|
||||
let _ = stream
|
||||
stream
|
||||
.write_all(b"GET /camel HTTP/1.1\r\nConnection: Close\r\n\r\n")
|
||||
.unwrap();
|
||||
let mut data = vec![];
|
||||
@ -251,7 +251,7 @@ mod tests {
|
||||
assert!(memmem::find(&data, b"content-length").is_none());
|
||||
|
||||
let mut stream = net::TcpStream::connect(srv.addr()).unwrap();
|
||||
let _ = stream
|
||||
stream
|
||||
.write_all(b"GET /lower HTTP/1.1\r\nConnection: Close\r\n\r\n")
|
||||
.unwrap();
|
||||
let mut data = vec![];
|
||||
|
@ -181,6 +181,25 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Configuration options used when accepting TLS connection.
|
||||
#[cfg(any(feature = "openssl", feature = "rustls"))]
|
||||
#[cfg_attr(docsrs, doc(cfg(any(feature = "openssl", feature = "rustls"))))]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct TlsAcceptorConfig {
|
||||
pub(crate) handshake_timeout: Option<std::time::Duration>,
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "openssl", feature = "rustls"))]
|
||||
impl TlsAcceptorConfig {
|
||||
/// Set TLS handshake timeout duration.
|
||||
pub fn handshake_timeout(self, dur: std::time::Duration) -> Self {
|
||||
Self {
|
||||
handshake_timeout: Some(dur),
|
||||
// ..self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "openssl")]
|
||||
mod openssl {
|
||||
use actix_service::ServiceFactoryExt as _;
|
||||
@ -230,7 +249,28 @@ mod openssl {
|
||||
Error = TlsError<SslError, DispatchError>,
|
||||
InitError = (),
|
||||
> {
|
||||
Acceptor::new(acceptor)
|
||||
self.openssl_with_config(acceptor, TlsAcceptorConfig::default())
|
||||
}
|
||||
|
||||
/// Create OpenSSL based service with custom TLS acceptor configuration.
|
||||
pub fn openssl_with_config(
|
||||
self,
|
||||
acceptor: SslAcceptor,
|
||||
tls_acceptor_config: TlsAcceptorConfig,
|
||||
) -> impl ServiceFactory<
|
||||
TcpStream,
|
||||
Config = (),
|
||||
Response = (),
|
||||
Error = TlsError<SslError, DispatchError>,
|
||||
InitError = (),
|
||||
> {
|
||||
let mut acceptor = Acceptor::new(acceptor);
|
||||
|
||||
if let Some(handshake_timeout) = tls_acceptor_config.handshake_timeout {
|
||||
acceptor.set_handshake_timeout(handshake_timeout);
|
||||
}
|
||||
|
||||
acceptor
|
||||
.map_init_err(|_| {
|
||||
unreachable!("TLS acceptor service factory does not error on init")
|
||||
})
|
||||
@ -293,8 +333,23 @@ mod rustls {
|
||||
{
|
||||
/// Create Rustls based service.
|
||||
pub fn rustls(
|
||||
self,
|
||||
config: ServerConfig,
|
||||
) -> impl ServiceFactory<
|
||||
TcpStream,
|
||||
Config = (),
|
||||
Response = (),
|
||||
Error = TlsError<io::Error, DispatchError>,
|
||||
InitError = (),
|
||||
> {
|
||||
self.rustls_with_config(config, TlsAcceptorConfig::default())
|
||||
}
|
||||
|
||||
/// Create Rustls based service with custom TLS acceptor configuration.
|
||||
pub fn rustls_with_config(
|
||||
self,
|
||||
mut config: ServerConfig,
|
||||
tls_acceptor_config: TlsAcceptorConfig,
|
||||
) -> impl ServiceFactory<
|
||||
TcpStream,
|
||||
Config = (),
|
||||
@ -306,7 +361,13 @@ mod rustls {
|
||||
protos.extend_from_slice(&config.alpn_protocols);
|
||||
config.alpn_protocols = protos;
|
||||
|
||||
Acceptor::new(config)
|
||||
let mut acceptor = Acceptor::new(config);
|
||||
|
||||
if let Some(handshake_timeout) = tls_acceptor_config.handshake_timeout {
|
||||
acceptor.set_handshake_timeout(handshake_timeout);
|
||||
}
|
||||
|
||||
acceptor
|
||||
.map_init_err(|_| {
|
||||
unreachable!("TLS acceptor service factory does not error on init")
|
||||
})
|
||||
|
@ -17,7 +17,6 @@ impl Parser {
|
||||
fn parse_metadata(
|
||||
src: &[u8],
|
||||
server: bool,
|
||||
max_size: usize,
|
||||
) -> Result<Option<(usize, bool, OpCode, usize, Option<[u8; 4]>)>, ProtocolError> {
|
||||
let chunk_len = src.len();
|
||||
|
||||
@ -60,20 +59,12 @@ impl Parser {
|
||||
return Ok(None);
|
||||
}
|
||||
let len = u64::from_be_bytes(TryFrom::try_from(&src[idx..idx + 8]).unwrap());
|
||||
if len > max_size as u64 {
|
||||
return Err(ProtocolError::Overflow);
|
||||
}
|
||||
idx += 8;
|
||||
len as usize
|
||||
} else {
|
||||
len as usize
|
||||
};
|
||||
|
||||
// check for max allowed size
|
||||
if length > max_size {
|
||||
return Err(ProtocolError::Overflow);
|
||||
}
|
||||
|
||||
let mask = if server {
|
||||
if chunk_len < idx + 4 {
|
||||
return Ok(None);
|
||||
@ -98,11 +89,10 @@ impl Parser {
|
||||
max_size: usize,
|
||||
) -> Result<Option<(bool, OpCode, Option<BytesMut>)>, ProtocolError> {
|
||||
// try to parse ws frame metadata
|
||||
let (idx, finished, opcode, length, mask) =
|
||||
match Parser::parse_metadata(src, server, max_size)? {
|
||||
None => return Ok(None),
|
||||
Some(res) => res,
|
||||
};
|
||||
let (idx, finished, opcode, length, mask) = match Parser::parse_metadata(src, server)? {
|
||||
None => return Ok(None),
|
||||
Some(res) => res,
|
||||
};
|
||||
|
||||
// not enough data
|
||||
if src.len() < idx + length {
|
||||
@ -112,6 +102,13 @@ impl Parser {
|
||||
// remove prefix
|
||||
src.advance(idx);
|
||||
|
||||
// check for max allowed size
|
||||
if length > max_size {
|
||||
// drop the payload
|
||||
src.advance(length);
|
||||
return Err(ProtocolError::Overflow);
|
||||
}
|
||||
|
||||
// no need for body
|
||||
if length == 0 {
|
||||
return Ok(Some((finished, opcode, None)));
|
||||
@ -339,6 +336,30 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_frame_max_size_recoverability() {
|
||||
let mut buf = BytesMut::new();
|
||||
// The first text frame with length == 2, payload doesn't matter.
|
||||
buf.extend(&[0b0000_0001u8, 0b0000_0010u8, 0b0000_0000u8, 0b0000_0000u8]);
|
||||
// Next binary frame with length == 2 and payload == `[0x1111_1111u8, 0x1111_1111u8]`.
|
||||
buf.extend(&[0b0000_0010u8, 0b0000_0010u8, 0b1111_1111u8, 0b1111_1111u8]);
|
||||
|
||||
assert_eq!(buf.len(), 8);
|
||||
assert!(matches!(
|
||||
Parser::parse(&mut buf, false, 1),
|
||||
Err(ProtocolError::Overflow)
|
||||
));
|
||||
assert_eq!(buf.len(), 4);
|
||||
let frame = extract(Parser::parse(&mut buf, false, 2));
|
||||
assert!(!frame.finished);
|
||||
assert_eq!(frame.opcode, OpCode::Binary);
|
||||
assert_eq!(
|
||||
frame.payload,
|
||||
Bytes::from(vec![0b1111_1111u8, 0b1111_1111u8])
|
||||
);
|
||||
assert_eq!(buf.len(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ping_frame() {
|
||||
let mut buf = BytesMut::new();
|
||||
|
@ -2,13 +2,13 @@
|
||||
|
||||
extern crate tls_openssl as openssl;
|
||||
|
||||
use std::{convert::Infallible, io};
|
||||
use std::{convert::Infallible, io, time::Duration};
|
||||
|
||||
use actix_http::{
|
||||
body::{BodyStream, BoxBody, SizedStream},
|
||||
error::PayloadError,
|
||||
header::{self, HeaderValue},
|
||||
Error, HttpService, Method, Request, Response, StatusCode, Version,
|
||||
Error, HttpService, Method, Request, Response, StatusCode, TlsAcceptorConfig, Version,
|
||||
};
|
||||
use actix_http_test::test_server;
|
||||
use actix_service::{fn_service, ServiceFactoryExt};
|
||||
@ -89,7 +89,10 @@ async fn h2_1() -> io::Result<()> {
|
||||
assert_eq!(req.version(), Version::HTTP_2);
|
||||
ok::<_, Error>(Response::ok())
|
||||
})
|
||||
.openssl(tls_config())
|
||||
.openssl_with_config(
|
||||
tls_config(),
|
||||
TlsAcceptorConfig::default().handshake_timeout(Duration::from_secs(5)),
|
||||
)
|
||||
.map_err(|_| ())
|
||||
})
|
||||
.await;
|
||||
|
@ -8,13 +8,14 @@ use std::{
|
||||
net::{SocketAddr, TcpStream as StdTcpStream},
|
||||
sync::Arc,
|
||||
task::Poll,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use actix_http::{
|
||||
body::{BodyStream, BoxBody, SizedStream},
|
||||
error::PayloadError,
|
||||
header::{self, HeaderName, HeaderValue},
|
||||
Error, HttpService, Method, Request, Response, StatusCode, Version,
|
||||
Error, HttpService, Method, Request, Response, StatusCode, TlsAcceptorConfig, Version,
|
||||
};
|
||||
use actix_http_test::test_server;
|
||||
use actix_rt::pin;
|
||||
@ -160,7 +161,10 @@ async fn h2_1() -> io::Result<()> {
|
||||
assert_eq!(req.version(), Version::HTTP_2);
|
||||
ok::<_, Error>(Response::ok())
|
||||
})
|
||||
.rustls(tls_config())
|
||||
.rustls_with_config(
|
||||
tls_config(),
|
||||
TlsAcceptorConfig::default().handshake_timeout(Duration::from_secs(5)),
|
||||
)
|
||||
})
|
||||
.await;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Changes
|
||||
|
||||
## Unreleased - 2021-xx-xx
|
||||
- Minimum supported Rust version (MSRV) is now 1.56 due to transitive `hashbrown` dependency.
|
||||
## Unreleased - 2022-xx-xx
|
||||
- Minimum supported Rust version (MSRV) is now 1.57 due to transitive `time` dependency.
|
||||
|
||||
|
||||
## 0.4.0 - 2022-02-25
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
[](https://crates.io/crates/actix-multipart)
|
||||
[](https://docs.rs/actix-multipart/0.4.0)
|
||||

|
||||

|
||||

|
||||
<br />
|
||||
[](https://deps.rs/crate/actix-multipart/0.4.0)
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Changes
|
||||
|
||||
## Unreleased - 2021-xx-xx
|
||||
- Minimum supported Rust version (MSRV) is now 1.56 due to transitive `hashbrown` dependency.
|
||||
## Unreleased - 2022-xx-xx
|
||||
- Minimum supported Rust version (MSRV) is now 1.57 due to transitive `time` dependency.
|
||||
|
||||
|
||||
## 0.5.0 - 2022-02-22
|
||||
|
@ -649,7 +649,7 @@ impl ResourceDef {
|
||||
/// resource.capture_match_info_fn(
|
||||
/// path,
|
||||
/// // when env var is not set, reject when path contains "admin"
|
||||
/// |res| !(!admin_allowed && res.path().contains("admin")),
|
||||
/// |path| !(!admin_allowed && path.as_str().contains("admin")),
|
||||
/// )
|
||||
/// }
|
||||
///
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Changes
|
||||
|
||||
## Unreleased - 2021-xx-xx
|
||||
- Minimum supported Rust version (MSRV) is now 1.56 due to transitive `hashbrown` dependency.
|
||||
## Unreleased - 2022-xx-xx
|
||||
- Minimum supported Rust version (MSRV) is now 1.57 due to transitive `time` dependency.
|
||||
|
||||
|
||||
## 0.1.0-beta.13 - 2022-02-16
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Changes
|
||||
|
||||
## Unreleased - 2021-xx-xx
|
||||
- Minimum supported Rust version (MSRV) is now 1.56 due to transitive `hashbrown` dependency.
|
||||
## Unreleased - 2022-xx-xx
|
||||
- Minimum supported Rust version (MSRV) is now 1.57 due to transitive `time` dependency.
|
||||
|
||||
|
||||
## 4.1.0 - 2022-03-02
|
||||
|
@ -29,6 +29,9 @@ tokio = { version = "1.13.1", features = ["sync"] }
|
||||
actix-rt = "2.2"
|
||||
actix-test = "0.1.0-beta.13"
|
||||
awc = { version = "3", default-features = false }
|
||||
actix-web = { version = "4", features = ["macros"] }
|
||||
|
||||
mime = "0.3"
|
||||
|
||||
env_logger = "0.9"
|
||||
futures-util = { version = "0.3.7", default-features = false }
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
[](https://crates.io/crates/actix-web-actors)
|
||||
[](https://docs.rs/actix-web-actors/4.1.0)
|
||||

|
||||

|
||||

|
||||
<br />
|
||||
[](https://deps.rs/crate/actix-web-actors/4.1.0)
|
||||
|
@ -14,6 +14,58 @@ use futures_core::Stream;
|
||||
use tokio::sync::oneshot::Sender;
|
||||
|
||||
/// Execution context for HTTP actors
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// A demonstration of [server-sent events](https://developer.mozilla.org/docs/Web/API/Server-sent_events) using actors:
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::time::Duration;
|
||||
///
|
||||
/// use actix::{Actor, AsyncContext};
|
||||
/// use actix_web::{get, http::header, App, HttpResponse, HttpServer};
|
||||
/// use actix_web_actors::HttpContext;
|
||||
/// use bytes::Bytes;
|
||||
///
|
||||
/// struct MyActor {
|
||||
/// count: usize,
|
||||
/// }
|
||||
///
|
||||
/// impl Actor for MyActor {
|
||||
/// type Context = HttpContext<Self>;
|
||||
///
|
||||
/// fn started(&mut self, ctx: &mut Self::Context) {
|
||||
/// ctx.run_later(Duration::from_millis(100), Self::write);
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// impl MyActor {
|
||||
/// fn write(&mut self, ctx: &mut HttpContext<Self>) {
|
||||
/// self.count += 1;
|
||||
/// if self.count > 3 {
|
||||
/// ctx.write_eof()
|
||||
/// } else {
|
||||
/// ctx.write(Bytes::from(format!("event: count\ndata: {}\n\n", self.count)));
|
||||
/// ctx.run_later(Duration::from_millis(100), Self::write);
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// #[get("/")]
|
||||
/// async fn index() -> HttpResponse {
|
||||
/// HttpResponse::Ok()
|
||||
/// .insert_header(header::ContentType(mime::TEXT_EVENT_STREAM))
|
||||
/// .streaming(HttpContext::create(MyActor { count: 0 }))
|
||||
/// }
|
||||
///
|
||||
/// #[actix_web::main]
|
||||
/// async fn main() -> std::io::Result<()> {
|
||||
/// HttpServer::new(|| App::new().service(index))
|
||||
/// .bind(("127.0.0.1", 8080))?
|
||||
/// .run()
|
||||
/// .await
|
||||
/// }
|
||||
/// ```
|
||||
pub struct HttpContext<A>
|
||||
where
|
||||
A: Actor<Context = HttpContext<A>>,
|
||||
@ -210,7 +262,7 @@ mod tests {
|
||||
type Context = HttpContext<Self>;
|
||||
|
||||
fn started(&mut self, ctx: &mut Self::Context) {
|
||||
ctx.run_later(Duration::from_millis(100), |slf, ctx| slf.write(ctx));
|
||||
ctx.run_later(Duration::from_millis(100), Self::write);
|
||||
}
|
||||
}
|
||||
|
||||
@ -221,7 +273,7 @@ mod tests {
|
||||
ctx.write_eof()
|
||||
} else {
|
||||
ctx.write(Bytes::from(format!("LINE-{}", self.count)));
|
||||
ctx.run_later(Duration::from_millis(100), |slf, ctx| slf.write(ctx));
|
||||
ctx.run_later(Duration::from_millis(100), Self::write);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,59 @@
|
||||
//! Actix actors support for Actix Web.
|
||||
//!
|
||||
//! # Examples
|
||||
//!
|
||||
//! ```no_run
|
||||
//! use actix::{Actor, StreamHandler};
|
||||
//! use actix_web::{get, web, App, Error, HttpRequest, HttpResponse, HttpServer};
|
||||
//! use actix_web_actors::ws;
|
||||
//!
|
||||
//! /// Define Websocket actor
|
||||
//! struct MyWs;
|
||||
//!
|
||||
//! impl Actor for MyWs {
|
||||
//! type Context = ws::WebsocketContext<Self>;
|
||||
//! }
|
||||
//!
|
||||
//! /// Handler for ws::Message message
|
||||
//! impl StreamHandler<Result<ws::Message, ws::ProtocolError>> for MyWs {
|
||||
//! fn handle(&mut self, msg: Result<ws::Message, ws::ProtocolError>, ctx: &mut Self::Context) {
|
||||
//! match msg {
|
||||
//! Ok(ws::Message::Ping(msg)) => ctx.pong(&msg),
|
||||
//! Ok(ws::Message::Text(text)) => ctx.text(text),
|
||||
//! Ok(ws::Message::Binary(bin)) => ctx.binary(bin),
|
||||
//! _ => (),
|
||||
//! }
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
//! #[get("/ws")]
|
||||
//! async fn index(req: HttpRequest, stream: web::Payload) -> Result<HttpResponse, Error> {
|
||||
//! ws::start(MyWs, &req, stream)
|
||||
//! }
|
||||
//!
|
||||
//! #[actix_web::main]
|
||||
//! async fn main() -> std::io::Result<()> {
|
||||
//! HttpServer::new(|| App::new().service(index))
|
||||
//! .bind(("127.0.0.1", 8080))?
|
||||
//! .run()
|
||||
//! .await
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! # Documentation & Community Resources
|
||||
//! In addition to this API documentation, several other resources are available:
|
||||
//!
|
||||
//! * [Website & User Guide](https://actix.rs/)
|
||||
//! * [Documentation for `actix_web`](actix_web)
|
||||
//! * [Examples Repository](https://github.com/actix/examples)
|
||||
//! * [Community Chat on Discord](https://discord.gg/NWpN5mmg3x)
|
||||
//!
|
||||
//! To get started navigating the API docs, you may consider looking at the following pages first:
|
||||
//!
|
||||
//! * [`ws`]: This module provides actor support for WebSockets.
|
||||
//!
|
||||
//! * [`HttpContext`]: This struct provides actor support for streaming HTTP responses.
|
||||
//!
|
||||
|
||||
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||
#![warn(future_incompatible)]
|
||||
|
@ -1,4 +1,60 @@
|
||||
//! Websocket integration.
|
||||
//!
|
||||
//! # Examples
|
||||
//!
|
||||
//! ```no_run
|
||||
//! use actix::{Actor, StreamHandler};
|
||||
//! use actix_web::{get, web, App, Error, HttpRequest, HttpResponse, HttpServer};
|
||||
//! use actix_web_actors::ws;
|
||||
//!
|
||||
//! /// Define Websocket actor
|
||||
//! struct MyWs;
|
||||
//!
|
||||
//! impl Actor for MyWs {
|
||||
//! type Context = ws::WebsocketContext<Self>;
|
||||
//! }
|
||||
//!
|
||||
//! /// Handler for ws::Message message
|
||||
//! impl StreamHandler<Result<ws::Message, ws::ProtocolError>> for MyWs {
|
||||
//! fn handle(&mut self, msg: Result<ws::Message, ws::ProtocolError>, ctx: &mut Self::Context) {
|
||||
//! match msg {
|
||||
//! Ok(ws::Message::Ping(msg)) => ctx.pong(&msg),
|
||||
//! Ok(ws::Message::Text(text)) => ctx.text(text),
|
||||
//! Ok(ws::Message::Binary(bin)) => ctx.binary(bin),
|
||||
//! _ => (),
|
||||
//! }
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
//! #[get("/ws")]
|
||||
//! async fn websocket(req: HttpRequest, stream: web::Payload) -> Result<HttpResponse, Error> {
|
||||
//! ws::start(MyWs, &req, stream)
|
||||
//! }
|
||||
//!
|
||||
//! const MAX_FRAME_SIZE: usize = 16_384; // 16KiB
|
||||
//!
|
||||
//! #[get("/custom-ws")]
|
||||
//! async fn custom_websocket(req: HttpRequest, stream: web::Payload) -> Result<HttpResponse, Error> {
|
||||
//! // Create a Websocket session with a specific max frame size, and protocols.
|
||||
//! ws::WsResponseBuilder::new(MyWs, &req, stream)
|
||||
//! .frame_size(MAX_FRAME_SIZE)
|
||||
//! .protocols(&["A", "B"])
|
||||
//! .start()
|
||||
//! }
|
||||
//!
|
||||
//! #[actix_web::main]
|
||||
//! async fn main() -> std::io::Result<()> {
|
||||
//! HttpServer::new(|| {
|
||||
//! App::new()
|
||||
//! .service(websocket)
|
||||
//! .service(custom_websocket)
|
||||
//! })
|
||||
//! .bind(("127.0.0.1", 8080))?
|
||||
//! .run()
|
||||
//! .await
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
|
||||
use std::{
|
||||
collections::VecDeque,
|
||||
@ -41,20 +97,51 @@ use tokio::sync::oneshot;
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Create a Websocket session response with default configuration.
|
||||
/// ```ignore
|
||||
/// WsResponseBuilder::new(WsActor, &req, stream).start()
|
||||
/// ```
|
||||
/// ```no_run
|
||||
/// # use actix::{Actor, StreamHandler};
|
||||
/// # use actix_web::{get, web, App, Error, HttpRequest, HttpResponse, HttpServer};
|
||||
/// # use actix_web_actors::ws;
|
||||
/// #
|
||||
/// # struct MyWs;
|
||||
/// #
|
||||
/// # impl Actor for MyWs {
|
||||
/// # type Context = ws::WebsocketContext<Self>;
|
||||
/// # }
|
||||
/// #
|
||||
/// # /// Handler for ws::Message message
|
||||
/// # impl StreamHandler<Result<ws::Message, ws::ProtocolError>> for MyWs {
|
||||
/// # fn handle(&mut self, msg: Result<ws::Message, ws::ProtocolError>, ctx: &mut Self::Context) {}
|
||||
/// # }
|
||||
/// #
|
||||
/// #[get("/ws")]
|
||||
/// async fn websocket(req: HttpRequest, stream: web::Payload) -> Result<HttpResponse, Error> {
|
||||
/// ws::WsResponseBuilder::new(MyWs, &req, stream).start()
|
||||
/// }
|
||||
///
|
||||
/// Create a Websocket session with a specific max frame size, [`Codec`], and protocols.
|
||||
/// ```ignore
|
||||
/// const MAX_FRAME_SIZE: usize = 16_384; // 16KiB
|
||||
///
|
||||
/// ws::WsResponseBuilder::new(WsActor, &req, stream)
|
||||
/// .codec(Codec::new())
|
||||
/// .protocols(&["A", "B"])
|
||||
/// .frame_size(MAX_FRAME_SIZE)
|
||||
/// .start()
|
||||
/// #[get("/custom-ws")]
|
||||
/// async fn custom_websocket(req: HttpRequest, stream: web::Payload) -> Result<HttpResponse, Error> {
|
||||
/// // Create a Websocket session with a specific max frame size, codec, and protocols.
|
||||
/// ws::WsResponseBuilder::new(MyWs, &req, stream)
|
||||
/// .codec(actix_http::ws::Codec::new())
|
||||
/// // This will overwrite the codec's max frame-size
|
||||
/// .frame_size(MAX_FRAME_SIZE)
|
||||
/// .protocols(&["A", "B"])
|
||||
/// .start()
|
||||
/// }
|
||||
/// #
|
||||
/// # #[actix_web::main]
|
||||
/// # async fn main() -> std::io::Result<()> {
|
||||
/// # HttpServer::new(|| {
|
||||
/// # App::new()
|
||||
/// # .service(websocket)
|
||||
/// # .service(custom_websocket)
|
||||
/// # })
|
||||
/// # .bind(("127.0.0.1", 8080))?
|
||||
/// # .run()
|
||||
/// # .await
|
||||
/// # }
|
||||
/// ```
|
||||
pub struct WsResponseBuilder<'a, A, T>
|
||||
where
|
||||
|
@ -1,6 +1,7 @@
|
||||
# Changes
|
||||
|
||||
## Unreleased - 2021-xx-xx
|
||||
## Unreleased - 2022-xx-xx
|
||||
- Minimum supported Rust version (MSRV) is now 1.57 due to transitive `time` dependency.
|
||||
|
||||
|
||||
## 4.0.1 - 2022-06-11
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
[](https://crates.io/crates/actix-web-codegen)
|
||||
[](https://docs.rs/actix-web-codegen/4.0.1)
|
||||

|
||||

|
||||

|
||||
<br />
|
||||
[](https://deps.rs/crate/actix-web-codegen/4.0.1)
|
||||
|
@ -1,4 +1,4 @@
|
||||
#[rustversion::stable(1.56)] // MSRV
|
||||
#[rustversion::stable(1.57)] // MSRV
|
||||
#[test]
|
||||
fn compile_macros() {
|
||||
let t = trybuild::TestCases::new();
|
||||
|
@ -1,11 +1,13 @@
|
||||
error: HTTP method defined more than once: `GET`
|
||||
--> $DIR/route-duplicate-method-fail.rs:3:35
|
||||
--> tests/trybuild/route-duplicate-method-fail.rs:3:35
|
||||
|
|
||||
3 | #[route("/", method="GET", method="GET")]
|
||||
| ^^^^^
|
||||
|
||||
error[E0277]: the trait bound `fn() -> impl std::future::Future {index}: HttpServiceFactory` is not satisfied
|
||||
--> $DIR/route-duplicate-method-fail.rs:12:55
|
||||
--> tests/trybuild/route-duplicate-method-fail.rs:12:55
|
||||
|
|
||||
12 | let srv = actix_test::start(|| App::new().service(index));
|
||||
| ^^^^^ the trait `HttpServiceFactory` is not implemented for `fn() -> impl std::future::Future {index}`
|
||||
| ------- ^^^^^ the trait `HttpServiceFactory` is not implemented for `fn() -> impl std::future::Future {index}`
|
||||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
@ -10,4 +10,6 @@ error[E0277]: the trait bound `fn() -> impl std::future::Future {index}: HttpSer
|
||||
--> tests/trybuild/route-missing-method-fail.rs:12:55
|
||||
|
|
||||
12 | let srv = actix_test::start(|| App::new().service(index));
|
||||
| ^^^^^ the trait `HttpServiceFactory` is not implemented for `fn() -> impl std::future::Future {index}`
|
||||
| ------- ^^^^^ the trait `HttpServiceFactory` is not implemented for `fn() -> impl std::future::Future {index}`
|
||||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
@ -1,11 +1,13 @@
|
||||
error: Unexpected HTTP method: `UNEXPECTED`
|
||||
--> $DIR/route-unexpected-method-fail.rs:3:21
|
||||
--> tests/trybuild/route-unexpected-method-fail.rs:3:21
|
||||
|
|
||||
3 | #[route("/", method="UNEXPECTED")]
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `fn() -> impl std::future::Future {index}: HttpServiceFactory` is not satisfied
|
||||
--> $DIR/route-unexpected-method-fail.rs:12:55
|
||||
--> tests/trybuild/route-unexpected-method-fail.rs:12:55
|
||||
|
|
||||
12 | let srv = actix_test::start(|| App::new().service(index));
|
||||
| ^^^^^ the trait `HttpServiceFactory` is not implemented for `fn() -> impl std::future::Future {index}`
|
||||
| ------- ^^^^^ the trait `HttpServiceFactory` is not implemented for `fn() -> impl std::future::Future {index}`
|
||||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
@ -1,6 +1,15 @@
|
||||
# Changelog
|
||||
|
||||
## Unreleased - 2021-xx-xx
|
||||
## Unreleased - 2022-xx-xx
|
||||
### Added
|
||||
- Add `ServiceRequest::{parts, request}()` getter methods. [#2786]
|
||||
- Add configuration options for TLS handshake timeout via `HttpServer::{rustls, openssl}_with_config` methods. [#2752]
|
||||
|
||||
### Changed
|
||||
- Minimum supported Rust version (MSRV) is now 1.57 due to transitive `time` dependency.
|
||||
|
||||
[#2752]: https://github.com/actix/actix-web/pull/2752
|
||||
[#2786]: https://github.com/actix/actix-web/pull/2786
|
||||
|
||||
|
||||
## 4.1.0 - 2022-06-11
|
||||
|
@ -105,14 +105,14 @@ actix-test = { version = "0.1.0-beta.13", features = ["openssl", "rustls"] }
|
||||
awc = { version = "3", features = ["openssl"] }
|
||||
|
||||
brotli = "3.3.3"
|
||||
const-str = "0.3"
|
||||
const-str = "0.4"
|
||||
criterion = { version = "0.3", features = ["html_reports"] }
|
||||
env_logger = "0.9"
|
||||
flate2 = "1.0.13"
|
||||
futures-util = { version = "0.3.7", default-features = false, features = ["std"] }
|
||||
rand = "0.8"
|
||||
rcgen = "0.8"
|
||||
rustls-pemfile = "0.2"
|
||||
rcgen = "0.9"
|
||||
rustls-pemfile = "1"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
static_assertions = "1"
|
||||
tls-openssl = { package = "openssl", version = "0.10.9" }
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
[](https://crates.io/crates/actix-web)
|
||||
[](https://docs.rs/actix-web/4.1.0)
|
||||

|
||||

|
||||

|
||||
[](https://deps.rs/crate/actix-web/4.1.0)
|
||||
<br />
|
||||
@ -33,7 +33,7 @@
|
||||
- SSL support using OpenSSL or Rustls
|
||||
- Middlewares ([Logger, Session, CORS, etc](https://actix.rs/docs/middleware/))
|
||||
- Integrates with the [`awc` HTTP client](https://docs.rs/awc/)
|
||||
- Runs on stable Rust 1.56+
|
||||
- Runs on stable Rust 1.57+
|
||||
|
||||
## Documentation
|
||||
|
||||
@ -79,6 +79,7 @@ async fn main() -> std::io::Result<()> {
|
||||
- [Application State](https://github.com/actix/examples/tree/master/basics/state)
|
||||
- [JSON Handling](https://github.com/actix/examples/tree/master/json/json)
|
||||
- [Multipart Streams](https://github.com/actix/examples/tree/master/forms/multipart)
|
||||
- [MongoDB Integration](https://github.com/actix/examples/tree/master/databases/mongodb)
|
||||
- [Diesel Integration](https://github.com/actix/examples/tree/master/databases/diesel)
|
||||
- [SQLite Integration](https://github.com/actix/examples/tree/master/databases/sqlite)
|
||||
- [Postgres Integration](https://github.com/actix/examples/tree/master/databases/postgres)
|
||||
|
@ -60,7 +60,7 @@ where
|
||||
/// [`HttpRequest::app_data`](crate::HttpRequest::app_data) method at runtime.
|
||||
///
|
||||
/// # [`Data<T>`]
|
||||
/// Any [`Data<T>`] type added here can utilize it's extractor implementation in handlers.
|
||||
/// Any [`Data<T>`] type added here can utilize its extractor implementation in handlers.
|
||||
/// Types not wrapped in `Data<T>` cannot use this extractor. See [its docs](Data<T>) for more
|
||||
/// about its usage and patterns.
|
||||
///
|
||||
|
@ -257,7 +257,7 @@ impl ServiceFactory<ServiceRequest> for AppRoutingFactory {
|
||||
type Future = LocalBoxFuture<'static, Result<Self::Service, Self::InitError>>;
|
||||
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
// construct all services factory future with it's resource def and guards.
|
||||
// construct all services factory future with its resource def and guards.
|
||||
let factory_fut = join_all(self.services.iter().map(|(path, factory, guards)| {
|
||||
let path = path.clone();
|
||||
let guards = guards.borrow_mut().take().unwrap_or_default();
|
||||
|
@ -153,6 +153,16 @@ impl AppConfig {
|
||||
}
|
||||
|
||||
impl Default for AppConfig {
|
||||
/// Returns the default AppConfig.
|
||||
/// Note: The included socket address is "127.0.0.1".
|
||||
///
|
||||
/// 127.0.0.1: non-routable meta address that denotes an unknown, invalid or non-applicable target.
|
||||
/// If you need a service only accessed by itself, use a loopback address.
|
||||
/// A loopback address for IPv4 is any loopback address that begins with "127".
|
||||
/// Loopback addresses should be only used to test your application locally.
|
||||
/// The default configuration provides a loopback address.
|
||||
///
|
||||
/// 0.0.0.0: if configured to use this special address, the application will listen to any IP address configured on the machine.
|
||||
fn default() -> Self {
|
||||
AppConfig::new(
|
||||
false,
|
||||
|
@ -254,7 +254,7 @@ impl Guard for AllGuard {
|
||||
}
|
||||
}
|
||||
|
||||
/// Wraps a guard and inverts the outcome of it's `Guard` implementation.
|
||||
/// Wraps a guard and inverts the outcome of its `Guard` implementation.
|
||||
///
|
||||
/// # Examples
|
||||
/// The handler below will be called for any request method apart from `GET`.
|
||||
@ -459,7 +459,7 @@ impl Guard for HostGuard {
|
||||
return scheme == req_host_uri_scheme;
|
||||
}
|
||||
|
||||
// TODO: is the the correct behavior?
|
||||
// TODO: is this the correct behavior?
|
||||
// falls through if scheme cannot be determined
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ use crate::{
|
||||
/// Thanks to Rust's type system, Actix Web can infer the function parameter types. During the
|
||||
/// extraction step, the parameter types are described as a tuple type, [`from_request`] is run on
|
||||
/// that tuple, and the `Handler::call` implementation for that particular function arity
|
||||
/// destructures the tuple into it's component types and calls your handler function with them.
|
||||
/// destructures the tuple into its component types and calls your handler function with them.
|
||||
///
|
||||
/// In pseudo-code the process looks something like this:
|
||||
/// ```ignore
|
||||
|
@ -251,6 +251,8 @@ static SUPPORTED_ENCODINGS: Lazy<Vec<Encoding>> = Lazy::new(|| {
|
||||
#[cfg(feature = "compress-gzip")]
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::collections::HashSet;
|
||||
|
||||
use super::*;
|
||||
use crate::{middleware::DefaultHeaders, test, web, App};
|
||||
|
||||
@ -305,4 +307,27 @@ mod tests {
|
||||
let bytes = test::read_body(res).await;
|
||||
assert_eq!(gzip_decode(bytes), DATA.as_bytes());
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn retains_previously_set_vary_header() {
|
||||
let app = test::init_service({
|
||||
App::new()
|
||||
.wrap(Compress::default())
|
||||
.default_service(web::to(move || {
|
||||
HttpResponse::Ok()
|
||||
.insert_header((header::VARY, "x-test"))
|
||||
.finish()
|
||||
}))
|
||||
})
|
||||
.await;
|
||||
|
||||
let req = test::TestRequest::default()
|
||||
.insert_header((header::ACCEPT_ENCODING, "gzip"))
|
||||
.to_request();
|
||||
let res = test::call_service(&app, req).await;
|
||||
assert_eq!(res.status(), StatusCode::OK);
|
||||
let vary_headers = res.headers().get_all(header::VARY).collect::<HashSet<_>>();
|
||||
assert!(vary_headers.contains(&HeaderValue::from_static("x-test")));
|
||||
assert!(vary_headers.contains(&HeaderValue::from_static("accept-encoding")));
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,31 @@
|
||||
//! For middleware documentation, see [`NormalizePath`].
|
||||
|
||||
use actix_http::uri::{PathAndQuery, Uri};
|
||||
use std::{
|
||||
future::Future,
|
||||
marker::PhantomData,
|
||||
pin::Pin,
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
use actix_service::{Service, Transform};
|
||||
use actix_utils::future::{ready, Ready};
|
||||
use bytes::Bytes;
|
||||
use futures_core::ready;
|
||||
use pin_project_lite::pin_project;
|
||||
use regex::Regex;
|
||||
|
||||
use crate::{
|
||||
body::EitherBody,
|
||||
http::{
|
||||
header,
|
||||
uri::{PathAndQuery, Uri},
|
||||
StatusCode,
|
||||
},
|
||||
service::{ServiceRequest, ServiceResponse},
|
||||
Error,
|
||||
Error, HttpResponse,
|
||||
};
|
||||
|
||||
/// Determines the behavior of the [`NormalizePath`] middleware.
|
||||
/// Determines the path rewriting behavior of the [`NormalizePath`] middleware.
|
||||
///
|
||||
/// The default is `TrailingSlash::Trim`.
|
||||
#[non_exhaustive]
|
||||
@ -86,7 +100,13 @@ impl Default for TrailingSlash {
|
||||
/// # })
|
||||
/// ```
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct NormalizePath(TrailingSlash);
|
||||
pub struct NormalizePath {
|
||||
/// Controls path normalization behavior.
|
||||
trailing_slash_behavior: TrailingSlash,
|
||||
|
||||
/// Returns redirects for non-normalized paths if `Some`.
|
||||
use_redirects: Option<StatusCode>,
|
||||
}
|
||||
|
||||
impl Default for NormalizePath {
|
||||
fn default() -> Self {
|
||||
@ -95,14 +115,20 @@ impl Default for NormalizePath {
|
||||
in v4 from `Always` to `Trim`. Update your call to `NormalizePath::new(...)`."
|
||||
);
|
||||
|
||||
Self(TrailingSlash::Trim)
|
||||
Self {
|
||||
trailing_slash_behavior: TrailingSlash::default(),
|
||||
use_redirects: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl NormalizePath {
|
||||
/// Create new `NormalizePath` middleware with the specified trailing slash style.
|
||||
pub fn new(trailing_slash_style: TrailingSlash) -> Self {
|
||||
Self(trailing_slash_style)
|
||||
pub fn new(behavior: TrailingSlash) -> Self {
|
||||
Self {
|
||||
trailing_slash_behavior: behavior,
|
||||
use_redirects: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Constructs a new `NormalizePath` middleware with [trim](TrailingSlash::Trim) semantics.
|
||||
@ -111,6 +137,32 @@ impl NormalizePath {
|
||||
pub fn trim() -> Self {
|
||||
Self::new(TrailingSlash::Trim)
|
||||
}
|
||||
|
||||
/// Configures middleware to respond to requests with non-normalized paths with a 307 redirect.
|
||||
///
|
||||
/// If configured
|
||||
///
|
||||
/// For example, a request with the path `/api//v1/foo/` would receive a response with a
|
||||
/// `Location: /api/v1/foo` header (assuming `Trim` trailing slash behavior.)
|
||||
///
|
||||
/// To customize the status code, use [`use_redirects_with`](Self::use_redirects_with).
|
||||
pub fn use_redirects(mut self) -> Self {
|
||||
self.use_redirects = Some(StatusCode::TEMPORARY_REDIRECT);
|
||||
self
|
||||
}
|
||||
|
||||
/// Configures middleware to respond to requests with non-normalized paths with a redirect.
|
||||
///
|
||||
/// For example, a request with the path `/api//v1/foo/` would receive a 307 response with a
|
||||
/// `Location: /api/v1/foo` header (assuming `Trim` trailing slash behavior.)
|
||||
///
|
||||
/// # Panics
|
||||
/// Panics if `status_code` is not a redirect (300-399).
|
||||
pub fn use_redirects_with(mut self, status_code: StatusCode) -> Self {
|
||||
assert!(status_code.is_redirection());
|
||||
self.use_redirects = Some(status_code);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<S, B> Transform<S, ServiceRequest> for NormalizePath
|
||||
@ -118,35 +170,37 @@ where
|
||||
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S::Future: 'static,
|
||||
{
|
||||
type Response = ServiceResponse<B>;
|
||||
type Response = ServiceResponse<EitherBody<B, ()>>;
|
||||
type Error = Error;
|
||||
type Transform = NormalizePathNormalization<S>;
|
||||
type Transform = NormalizePathService<S>;
|
||||
type InitError = ();
|
||||
type Future = Ready<Result<Self::Transform, Self::InitError>>;
|
||||
|
||||
fn new_transform(&self, service: S) -> Self::Future {
|
||||
ready(Ok(NormalizePathNormalization {
|
||||
ready(Ok(NormalizePathService {
|
||||
service,
|
||||
merge_slash: Regex::new("//+").unwrap(),
|
||||
trailing_slash_behavior: self.0,
|
||||
trailing_slash_behavior: self.trailing_slash_behavior,
|
||||
use_redirects: self.use_redirects,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct NormalizePathNormalization<S> {
|
||||
pub struct NormalizePathService<S> {
|
||||
service: S,
|
||||
merge_slash: Regex,
|
||||
trailing_slash_behavior: TrailingSlash,
|
||||
use_redirects: Option<StatusCode>,
|
||||
}
|
||||
|
||||
impl<S, B> Service<ServiceRequest> for NormalizePathNormalization<S>
|
||||
impl<S, B> Service<ServiceRequest> for NormalizePathService<S>
|
||||
where
|
||||
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S::Future: 'static,
|
||||
{
|
||||
type Response = ServiceResponse<B>;
|
||||
type Response = ServiceResponse<EitherBody<B, ()>>;
|
||||
type Error = Error;
|
||||
type Future = S::Future;
|
||||
type Future = NormalizePathFuture<S, B>;
|
||||
|
||||
actix_service::forward_ready!(service);
|
||||
|
||||
@ -189,7 +243,7 @@ where
|
||||
let query = parts.path_and_query.as_ref().and_then(|pq| pq.query());
|
||||
|
||||
let path = match query {
|
||||
Some(q) => Bytes::from(format!("{}?{}", path, q)),
|
||||
Some(query) => Bytes::from(format!("{}?{}", path, query)),
|
||||
None => Bytes::copy_from_slice(path.as_bytes()),
|
||||
};
|
||||
parts.path_and_query = Some(PathAndQuery::from_maybe_shared(path).unwrap());
|
||||
@ -199,20 +253,87 @@ where
|
||||
req.head_mut().uri = uri;
|
||||
}
|
||||
}
|
||||
self.service.call(req)
|
||||
|
||||
match self.use_redirects {
|
||||
Some(code) => {
|
||||
let mut res = HttpResponse::with_body(code, ());
|
||||
res.headers_mut().insert(
|
||||
header::LOCATION,
|
||||
req.head_mut().uri.to_string().parse().unwrap(),
|
||||
);
|
||||
NormalizePathFuture::redirect(req.into_response(res))
|
||||
}
|
||||
|
||||
None => NormalizePathFuture::service(self.service.call(req)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pin_project! {
|
||||
pub struct NormalizePathFuture<S: Service<ServiceRequest>, B> {
|
||||
#[pin] inner: Inner<S, B>,
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: Service<ServiceRequest>, B> NormalizePathFuture<S, B> {
|
||||
fn service(fut: S::Future) -> Self {
|
||||
Self {
|
||||
inner: Inner::Service {
|
||||
fut,
|
||||
_body: PhantomData,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn redirect(res: ServiceResponse<()>) -> Self {
|
||||
Self {
|
||||
inner: Inner::Redirect { res: Some(res) },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pin_project! {
|
||||
#[project = InnerProj]
|
||||
enum Inner<S: Service<ServiceRequest>, B> {
|
||||
Redirect { res: Option<ServiceResponse<()>>, },
|
||||
Service {
|
||||
#[pin] fut: S::Future,
|
||||
_body: PhantomData<B>,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
impl<S, B> Future for NormalizePathFuture<S, B>
|
||||
where
|
||||
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
{
|
||||
type Output = Result<ServiceResponse<EitherBody<B, ()>>, Error>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let this = self.project();
|
||||
|
||||
match this.inner.project() {
|
||||
InnerProj::Redirect { res } => {
|
||||
Poll::Ready(Ok(res.take().unwrap().map_into_right_body()))
|
||||
}
|
||||
|
||||
InnerProj::Service { fut, .. } => {
|
||||
let res = ready!(fut.poll(cx))?;
|
||||
Poll::Ready(Ok(res.map_into_left_body()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use actix_http::StatusCode;
|
||||
use actix_service::IntoService;
|
||||
|
||||
use super::*;
|
||||
use crate::{
|
||||
dev::ServiceRequest,
|
||||
guard::fn_guard,
|
||||
test::{call_service, init_service, TestRequest},
|
||||
test::{self, call_service, init_service, TestRequest},
|
||||
web, App, HttpResponse,
|
||||
};
|
||||
|
||||
@ -256,7 +377,7 @@ mod tests {
|
||||
async fn trim_trailing_slashes() {
|
||||
let app = init_service(
|
||||
App::new()
|
||||
.wrap(NormalizePath(TrailingSlash::Trim))
|
||||
.wrap(NormalizePath::new(TrailingSlash::Trim))
|
||||
.service(web::resource("/").to(HttpResponse::Ok))
|
||||
.service(web::resource("/v1/something").to(HttpResponse::Ok))
|
||||
.service(
|
||||
@ -292,11 +413,13 @@ mod tests {
|
||||
#[actix_rt::test]
|
||||
async fn trim_root_trailing_slashes_with_query() {
|
||||
let app = init_service(
|
||||
App::new().wrap(NormalizePath(TrailingSlash::Trim)).service(
|
||||
web::resource("/")
|
||||
.guard(fn_guard(|ctx| ctx.head().uri.query() == Some("query=test")))
|
||||
.to(HttpResponse::Ok),
|
||||
),
|
||||
App::new()
|
||||
.wrap(NormalizePath::new(TrailingSlash::Trim))
|
||||
.service(
|
||||
web::resource("/")
|
||||
.guard(fn_guard(|ctx| ctx.head().uri.query() == Some("query=test")))
|
||||
.to(HttpResponse::Ok),
|
||||
),
|
||||
)
|
||||
.await;
|
||||
|
||||
@ -313,7 +436,7 @@ mod tests {
|
||||
async fn ensure_trailing_slash() {
|
||||
let app = init_service(
|
||||
App::new()
|
||||
.wrap(NormalizePath(TrailingSlash::Always))
|
||||
.wrap(NormalizePath::new(TrailingSlash::Always))
|
||||
.service(web::resource("/").to(HttpResponse::Ok))
|
||||
.service(web::resource("/v1/something/").to(HttpResponse::Ok))
|
||||
.service(
|
||||
@ -350,7 +473,7 @@ mod tests {
|
||||
async fn ensure_root_trailing_slash_with_query() {
|
||||
let app = init_service(
|
||||
App::new()
|
||||
.wrap(NormalizePath(TrailingSlash::Always))
|
||||
.wrap(NormalizePath::new(TrailingSlash::Always))
|
||||
.service(
|
||||
web::resource("/")
|
||||
.guard(fn_guard(|ctx| ctx.head().uri.query() == Some("query=test")))
|
||||
@ -372,7 +495,7 @@ mod tests {
|
||||
async fn keep_trailing_slash_unchanged() {
|
||||
let app = init_service(
|
||||
App::new()
|
||||
.wrap(NormalizePath(TrailingSlash::MergeOnly))
|
||||
.wrap(NormalizePath::new(TrailingSlash::MergeOnly))
|
||||
.service(web::resource("/").to(HttpResponse::Ok))
|
||||
.service(web::resource("/v1/something").to(HttpResponse::Ok))
|
||||
.service(web::resource("/v1/").to(HttpResponse::Ok))
|
||||
@ -486,4 +609,27 @@ mod tests {
|
||||
let res = normalize.call(req).await.unwrap();
|
||||
assert!(res.status().is_success());
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn should_return_redirects_when_configured() {
|
||||
let normalize = NormalizePath::trim()
|
||||
.use_redirects()
|
||||
.new_transform(test::ok_service())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let req = TestRequest::with_uri("/v1/something/").to_srv_request();
|
||||
let res = normalize.call(req).await.unwrap();
|
||||
assert_eq!(res.status(), StatusCode::TEMPORARY_REDIRECT);
|
||||
|
||||
let normalize = NormalizePath::trim()
|
||||
.use_redirects_with(StatusCode::PERMANENT_REDIRECT)
|
||||
.new_transform(test::ok_service())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let req = TestRequest::with_uri("/v1/something/").to_srv_request();
|
||||
let res = normalize.call(req).await.unwrap();
|
||||
assert_eq!(res.status(), StatusCode::PERMANENT_REDIRECT);
|
||||
}
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ mod response_fut_impl {
|
||||
|
||||
// Future is only implemented for BoxBody payload type because it's the most useful for making
|
||||
// simple handlers without async blocks. Making it generic over all MessageBody types requires a
|
||||
// future impl on Response which would cause it's body field to be, undesirably, Option<B>.
|
||||
// future impl on Response which would cause its body field to be, undesirably, Option<B>.
|
||||
//
|
||||
// This impl is not particularly efficient due to the Response construction and should probably
|
||||
// not be invoked if performance is important. Prefer an async fn/block in such cases.
|
||||
|
@ -18,6 +18,9 @@ use actix_tls::accept::openssl::reexports::{AlpnError, SslAcceptor, SslAcceptorB
|
||||
#[cfg(feature = "rustls")]
|
||||
use actix_tls::accept::rustls::reexports::ServerConfig as RustlsServerConfig;
|
||||
|
||||
#[cfg(any(feature = "openssl", feature = "rustls"))]
|
||||
use actix_http::TlsAcceptorConfig;
|
||||
|
||||
use crate::{config::AppConfig, Error};
|
||||
|
||||
struct Socket {
|
||||
@ -30,6 +33,8 @@ struct Config {
|
||||
keep_alive: KeepAlive,
|
||||
client_request_timeout: Duration,
|
||||
client_disconnect_timeout: Duration,
|
||||
#[cfg(any(feature = "openssl", feature = "rustls"))]
|
||||
tls_handshake_timeout: Option<Duration>,
|
||||
}
|
||||
|
||||
/// An HTTP Server.
|
||||
@ -92,6 +97,8 @@ where
|
||||
keep_alive: KeepAlive::default(),
|
||||
client_request_timeout: Duration::from_secs(5),
|
||||
client_disconnect_timeout: Duration::from_secs(1),
|
||||
#[cfg(any(feature = "rustls", feature = "openssl"))]
|
||||
tls_handshake_timeout: None,
|
||||
})),
|
||||
backlog: 1024,
|
||||
sockets: Vec::new(),
|
||||
@ -225,6 +232,24 @@ where
|
||||
self
|
||||
}
|
||||
|
||||
/// Set TLS handshake timeout.
|
||||
///
|
||||
/// Defines a timeout for TLS handshake. If the TLS handshake does not complete
|
||||
/// within this time, the connection is closed.
|
||||
///
|
||||
/// By default handshake timeout is set to 3000 milliseconds.
|
||||
#[cfg(any(feature = "openssl", feature = "rustls"))]
|
||||
#[cfg_attr(docsrs, doc(cfg(any(feature = "openssl", feature = "rustls"))))]
|
||||
pub fn tls_handshake_timeout(self, dur: Duration) -> Self {
|
||||
self.config
|
||||
.lock()
|
||||
.unwrap()
|
||||
.tls_handshake_timeout
|
||||
.replace(dur);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
#[deprecated(since = "4.0.0", note = "Renamed to `client_disconnect_timeout`.")]
|
||||
pub fn client_shutdown(self, dur: u64) -> Self {
|
||||
@ -376,10 +401,15 @@ where
|
||||
.into_factory()
|
||||
.map_err(|err| err.into().error_response());
|
||||
|
||||
let acceptor_config = match c.tls_handshake_timeout {
|
||||
Some(dur) => TlsAcceptorConfig::default().handshake_timeout(dur),
|
||||
None => TlsAcceptorConfig::default(),
|
||||
};
|
||||
|
||||
svc.finish(map_config(fac, move |_| {
|
||||
AppConfig::new(true, host.clone(), addr)
|
||||
}))
|
||||
.openssl(acceptor.clone())
|
||||
.openssl_with_config(acceptor.clone(), acceptor_config)
|
||||
})?;
|
||||
|
||||
Ok(self)
|
||||
@ -434,10 +464,15 @@ where
|
||||
.into_factory()
|
||||
.map_err(|err| err.into().error_response());
|
||||
|
||||
let acceptor_config = match c.tls_handshake_timeout {
|
||||
Some(dur) => TlsAcceptorConfig::default().handshake_timeout(dur),
|
||||
None => TlsAcceptorConfig::default(),
|
||||
};
|
||||
|
||||
svc.finish(map_config(fac, move |_| {
|
||||
AppConfig::new(true, host.clone(), addr)
|
||||
}))
|
||||
.rustls(config.clone())
|
||||
.rustls_with_config(config.clone(), acceptor_config)
|
||||
})?;
|
||||
|
||||
Ok(self)
|
||||
|
@ -95,6 +95,18 @@ impl ServiceRequest {
|
||||
(&mut self.req, &mut self.payload)
|
||||
}
|
||||
|
||||
/// Returns immutable accessors to inner parts.
|
||||
#[inline]
|
||||
pub fn parts(&self) -> (&HttpRequest, &Payload) {
|
||||
(&self.req, &self.payload)
|
||||
}
|
||||
|
||||
/// Returns immutable accessor to inner [`HttpRequest`].
|
||||
#[inline]
|
||||
pub fn request(&self) -> &HttpRequest {
|
||||
&self.req
|
||||
}
|
||||
|
||||
/// Derives a type from this request using an [extractor](crate::FromRequest).
|
||||
///
|
||||
/// Returns the `T` extractor's `Future` type which can be `await`ed. This is particularly handy
|
||||
|
@ -183,6 +183,7 @@ mod tests {
|
||||
assert!(Path::<MyStruct>::from_request(&req, &mut pl).await.is_err());
|
||||
}
|
||||
|
||||
#[allow(clippy::let_unit_value)]
|
||||
#[actix_rt::test]
|
||||
async fn test_tuple_extract() {
|
||||
let resource = ResourceDef::new("/{key}/{value}/");
|
||||
|
@ -113,7 +113,7 @@ pub struct BytesExtractFut {
|
||||
body_fut: HttpMessageBody,
|
||||
}
|
||||
|
||||
impl<'a> Future for BytesExtractFut {
|
||||
impl Future for BytesExtractFut {
|
||||
type Output = Result<Bytes, Error>;
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
@ -167,7 +167,7 @@ pub struct StringExtractFut {
|
||||
encoding: &'static Encoding,
|
||||
}
|
||||
|
||||
impl<'a> Future for StringExtractFut {
|
||||
impl Future for StringExtractFut {
|
||||
type Output = Result<String, Error>;
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
|
@ -1,8 +1,8 @@
|
||||
# Changes
|
||||
|
||||
## Unreleased - 2021-xx-xx
|
||||
## Unreleased - 2022-xx-xx
|
||||
### Changed
|
||||
- Minimum supported Rust version (MSRV) is now 1.56 due to transitive `hashbrown` dependency.
|
||||
- Minimum supported Rust version (MSRV) is now 1.57 due to transitive `time` dependency.
|
||||
|
||||
|
||||
## 3.0.0 - 2022-03-07
|
||||
|
@ -90,7 +90,7 @@ cookie = { version = "0.16", features = ["percent-encode"], optional = true }
|
||||
tls-openssl = { package = "openssl", version = "0.10.9", optional = true }
|
||||
tls-rustls = { package = "rustls", version = "0.20.0", optional = true, features = ["dangerous_configuration"] }
|
||||
|
||||
trust-dns-resolver = { version = "0.20.0", optional = true }
|
||||
trust-dns-resolver = { version = "0.21", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
actix-http = { version = "3", features = ["openssl"] }
|
||||
@ -102,13 +102,13 @@ actix-utils = "3"
|
||||
actix-web = { version = "4", features = ["openssl"] }
|
||||
|
||||
brotli = "3.3.3"
|
||||
const-str = "0.3"
|
||||
const-str = "0.4"
|
||||
env_logger = "0.9"
|
||||
flate2 = "1.0.13"
|
||||
futures-util = { version = "0.3.7", default-features = false }
|
||||
static_assertions = "1.1"
|
||||
rcgen = "0.8"
|
||||
rustls-pemfile = "0.2"
|
||||
rcgen = "0.9"
|
||||
rustls-pemfile = "1"
|
||||
tokio = { version = "1.13.1", features = ["rt-multi-thread", "macros"] }
|
||||
zstd = "0.11"
|
||||
|
||||
|
@ -1 +1 @@
|
||||
msrv = "1.56"
|
||||
msrv = "1.57"
|
||||
|
Reference in New Issue
Block a user