diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index fa06a137a..a26842245 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -3,34 +3,40 @@ name: Bug Report about: Create a bug report. --- -Your issue may already be reported! -Please search on the [Actix Web issue tracker](https://github.com/actix/actix-web/issues) before creating one. +Your issue may already be reported! Please search on the [Actix Web issue tracker](https://github.com/actix/actix-web/issues) before creating one. ## Expected Behavior + ## Current Behavior + ## Possible Solution + ## Steps to Reproduce (for bugs) + + 1. 2. 3. 4. ## Context + ## Your Environment + - Rust Version (I.e, output of `rustc -V`): diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index d617cf708..e0d17fb27 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -2,12 +2,14 @@ ## PR Type + + PR_TYPE - ## PR Checklist + @@ -17,11 +19,10 @@ PR_TYPE - [ ] Format code with the latest stable rustfmt. - [ ] (Team) Label with affected crates and semver status. - ## Overview + - diff --git a/.prettierrc.json b/.prettierrc.json deleted file mode 100644 index 677ba8ef2..000000000 --- a/.prettierrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "proseWrap": "never" -} diff --git a/.prettierrc.yaml b/.prettierrc.yaml new file mode 100644 index 000000000..7b5590248 --- /dev/null +++ b/.prettierrc.yaml @@ -0,0 +1 @@ +proseWrap: never diff --git a/Cargo.toml b/Cargo.toml index 26b5b91b2..65e3c6ae8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ members = [ "actix-http-test", "actix-http", "actix-multipart", + "actix-multipart-derive", "actix-router", "actix-test", "actix-web-actors", @@ -27,6 +28,7 @@ actix-files = { path = "actix-files" } actix-http = { path = "actix-http" } actix-http-test = { path = "actix-http-test" } actix-multipart = { path = "actix-multipart" } +actix-multipart-derive = { path = "actix-multipart-derive" } actix-router = { path = "actix-router" } actix-test = { path = "actix-test" } actix-web = { path = "actix-web" } diff --git a/actix-files/CHANGES.md b/actix-files/CHANGES.md index 6e57bf7a7..b4b2fd8c1 100644 --- a/actix-files/CHANGES.md +++ b/actix-files/CHANGES.md @@ -1,19 +1,24 @@ # Changes ## Unreleased - 2022-xx-xx + +## 0.6.3 - 2023-01-21 + - XHTML files now use `Content-Disposition: inline` instead of `attachment`. [#2903] - Minimum supported Rust version (MSRV) is now 1.59 due to transitive `time` dependency. +- Update `tokio-uring` dependency to `0.4`. [#2903]: https://github.com/actix/actix-web/pull/2903 ## 0.6.2 - 2022-07-23 + - Allow partial range responses for video content to start streaming sooner. [#2817] - Minimum supported Rust version (MSRV) is now 1.57 due to transitive `time` dependency. [#2817]: https://github.com/actix/actix-web/pull/2817 - ## 0.6.1 - 2022-06-11 + - Add `NamedFile::{modified, metadata, content_type, content_disposition, encoding}()` getters. [#2021] - Update `tokio-uring` dependency to `0.3`. - Audio files now use `Content-Disposition: inline` instead of `attachment`. [#2645] @@ -22,46 +27,46 @@ [#2021]: https://github.com/actix/actix-web/pull/2021 [#2645]: https://github.com/actix/actix-web/pull/2645 - ## 0.6.0 - 2022-02-25 + - No significant changes since `0.6.0-beta.16`. - ## 0.6.0-beta.16 - 2022-01-31 + - No significant changes since `0.6.0-beta.15`. - ## 0.6.0-beta.15 - 2022-01-21 + - No significant changes since `0.6.0-beta.14`. - ## 0.6.0-beta.14 - 2022-01-14 + - The `prefer_utf8` option introduced in `0.4.0` is now true by default. [#2583] [#2583]: https://github.com/actix/actix-web/pull/2583 - ## 0.6.0-beta.13 - 2022-01-04 + - The `Files` service now rejects requests with URL paths that include `%2F` (decoded: `/`). [#2398] - The `Files` service now correctly decodes `%25` in the URL path to `%` for the file path. [#2398] - Minimum supported Rust version (MSRV) is now 1.54. [#2398]: https://github.com/actix/actix-web/pull/2398 - ## 0.6.0-beta.12 - 2021-12-29 + - No significant changes since `0.6.0-beta.11`. - ## 0.6.0-beta.11 - 2021-12-27 + - No significant changes since `0.6.0-beta.10`. - ## 0.6.0-beta.10 - 2021-12-11 + - No significant changes since `0.6.0-beta.9`. - ## 0.6.0-beta.9 - 2021-11-22 + - Add crate feature `experimental-io-uring`, enabling async file I/O to be utilized. This feature is only available on Linux OSes with recent kernel versions. This feature is semver-exempt. [#2408] - Add `NamedFile::open_async`. [#2408] - Fix 304 Not Modified responses to omit the Content-Length header, as per the spec. [#2453] @@ -72,24 +77,24 @@ [#2408]: https://github.com/actix/actix-web/pull/2408 [#2453]: https://github.com/actix/actix-web/pull/2453 - ## 0.6.0-beta.8 - 2021-10-20 + - Minimum supported Rust version (MSRV) is now 1.52. - ## 0.6.0-beta.7 - 2021-09-09 + - Minimum supported Rust version (MSRV) is now 1.51. - ## 0.6.0-beta.6 - 2021-06-26 + - Added `Files::path_filter()`. [#2274] - `Files::show_files_listing()` can now be used with `Files::index_file()` to show files listing as a fallback when the index file is not found. [#2228] [#2274]: https://github.com/actix/actix-web/pull/2274 [#2228]: https://github.com/actix/actix-web/pull/2228 - ## 0.6.0-beta.5 - 2021-06-17 + - `NamedFile` now implements `ServiceFactory` and `HttpServiceFactory` making it much more useful in routing. For example, it can be used directly as a default service. [#2135] - For symbolic links, `Content-Disposition` header no longer shows the filename of the original file. [#2156] - `Files::redirect_to_slash_directory()` now works as expected when used with `Files::show_files_listing()`. [#2225] @@ -100,58 +105,58 @@ [#2225]: https://github.com/actix/actix-web/pull/2225 [#2257]: https://github.com/actix/actix-web/pull/2257 - ## 0.6.0-beta.4 - 2021-04-02 + - Add support for `.guard` in `Files` to selectively filter `Files` services. [#2046] [#2046]: https://github.com/actix/actix-web/pull/2046 - ## 0.6.0-beta.3 - 2021-03-09 + - No notable changes. - ## 0.6.0-beta.2 - 2021-02-10 + - Fix If-Modified-Since and If-Unmodified-Since to not compare using sub-second timestamps. [#1887] - Replace `v_htmlescape` with `askama_escape`. [#1953] [#1887]: https://github.com/actix/actix-web/pull/1887 [#1953]: https://github.com/actix/actix-web/pull/1953 - ## 0.6.0-beta.1 - 2021-01-07 + - `HttpRange::parse` now has its own error type. - Update `bytes` to `1.0`. [#1813] [#1813]: https://github.com/actix/actix-web/pull/1813 - ## 0.5.0 - 2020-12-26 + - Optionally support hidden files/directories. [#1811] [#1811]: https://github.com/actix/actix-web/pull/1811 - ## 0.4.1 - 2020-11-24 + - Clarify order of parameters in `Files::new` and improve docs. - ## 0.4.0 - 2020-10-06 + - Add `Files::prefer_utf8` option that adds UTF-8 charset on certain response types. [#1714] [#1714]: https://github.com/actix/actix-web/pull/1714 - ## 0.3.0 - 2020-09-11 + - No significant changes from 0.3.0-beta.1. - ## 0.3.0-beta.1 - 2020-07-15 + - Update `v_htmlescape` to 0.10 - Update `actix-web` and `actix-http` dependencies to beta.1 - ## 0.3.0-alpha.1 - 2020-05-23 + - Update `actix-web` and `actix-http` dependencies to alpha - Fix some typos in the docs - Bump minimum supported Rust version to 1.40 @@ -159,73 +164,73 @@ [#1384]: https://github.com/actix/actix-web/pull/1384 - ## 0.2.1 - 2019-12-22 + - Use the same format for file URLs regardless of platforms - ## 0.2.0 - 2019-12-20 + - Fix BodyEncoding trait import #1220 - ## 0.2.0-alpha.1 - 2019-12-07 + - Migrate to `std::future` - ## 0.1.7 - 2019-11-06 -- Add an additional `filename*` param in the `Content-Disposition` header of - `actix_files::NamedFile` to be more compatible. (#1151) + +- Add an additional `filename*` param in the `Content-Disposition` header of `actix_files::NamedFile` to be more compatible. (#1151) ## 0.1.6 - 2019-10-14 + - Add option to redirect to a slash-ended path `Files` #1132 - ## 0.1.5 - 2019-10-08 + - Bump up `mime_guess` crate version to 2.0.1 - Bump up `percent-encoding` crate version to 2.1 - Allow user defined request guards for `Files` #1113 - ## 0.1.4 - 2019-07-20 + - Allow to disable `Content-Disposition` header #686 - ## 0.1.3 - 2019-06-28 + - Do not set `Content-Length` header, let actix-http set it #930 - ## 0.1.2 - 2019-06-13 + - Content-Length is 0 for NamedFile HEAD request #914 - Fix ring dependency from actix-web default features for #741 - ## 0.1.1 - 2019-06-01 + - Static files are incorrectly served as both chunked and with length #812 - ## 0.1.0 - 2019-05-25 + - NamedFile last-modified check always fails due to nano-seconds in file modified date #820 - ## 0.1.0-beta.4 - 2019-05-12 + - Update actix-web to beta.4 - ## 0.1.0-beta.1 - 2019-04-20 + - Update actix-web to beta.1 - ## 0.1.0-alpha.6 - 2019-04-14 + - Update actix-web to alpha6 - ## 0.1.0-alpha.4 - 2019-04-08 + - Update actix-web to alpha4 - ## 0.1.0-alpha.2 - 2019-04-02 + - Add default handler support - ## 0.1.0-alpha.1 - 2019-03-28 + - Initial impl diff --git a/actix-files/Cargo.toml b/actix-files/Cargo.toml index 01dc2928a..4c29c95b2 100644 --- a/actix-files/Cargo.toml +++ b/actix-files/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-files" -version = "0.6.2" +version = "0.6.3" authors = [ "Nikolay Kim ", "Rob Ede ", @@ -40,8 +40,8 @@ v_htmlescape= "0.15" # experimental-io-uring [target.'cfg(target_os = "linux")'.dependencies] -tokio-uring = { version = "0.3", optional = true, features = ["bytes"] } -actix-server = { version = "2.1", optional = true } # ensure matching tokio-uring versions +tokio-uring = { version = "0.4", optional = true, features = ["bytes"] } +actix-server = { version = "2.2", optional = true } # ensure matching tokio-uring versions [dev-dependencies] actix-rt = "2.7" diff --git a/actix-files/README.md b/actix-files/README.md index a5078c8d5..8869ca436 100644 --- a/actix-files/README.md +++ b/actix-files/README.md @@ -3,11 +3,11 @@ > Static file serving for Actix Web [![crates.io](https://img.shields.io/crates/v/actix-files?label=latest)](https://crates.io/crates/actix-files) -[![Documentation](https://docs.rs/actix-files/badge.svg?version=0.6.2)](https://docs.rs/actix-files/0.6.2) +[![Documentation](https://docs.rs/actix-files/badge.svg?version=0.6.3)](https://docs.rs/actix-files/0.6.3) ![Version](https://img.shields.io/badge/rustc-1.59+-ab6000.svg) ![License](https://img.shields.io/crates/l/actix-files.svg)
-[![dependency status](https://deps.rs/crate/actix-files/0.6.2/status.svg)](https://deps.rs/crate/actix-files/0.6.2) +[![dependency status](https://deps.rs/crate/actix-files/0.6.3/status.svg)](https://deps.rs/crate/actix-files/0.6.3) [![Download](https://img.shields.io/crates/d/actix-files.svg)](https://crates.io/crates/actix-files) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) @@ -15,4 +15,4 @@ - [API Documentation](https://docs.rs/actix-files) - [Example Project](https://github.com/actix/examples/tree/master/basics/static-files) -- Minimum Supported Rust Version (MSRV): 1.54 +- Minimum Supported Rust Version (MSRV): 1.59 diff --git a/actix-files/src/files.rs b/actix-files/src/files.rs index a30ce6fd3..be2a450d2 100644 --- a/actix-files/src/files.rs +++ b/actix-files/src/files.rs @@ -142,7 +142,7 @@ impl Files { self } - /// Set custom directory renderer + /// Set custom directory renderer. pub fn files_listing_renderer(mut self, f: F) -> Self where for<'r, 's> F: @@ -152,7 +152,7 @@ impl Files { self } - /// Specifies mime override callback + /// Specifies MIME override callback. pub fn mime_override(mut self, f: F) -> Self where F: Fn(&mime::Name<'_>) -> DispositionType + 'static, @@ -390,3 +390,42 @@ impl ServiceFactory for Files { } } } + +#[cfg(test)] +mod tests { + use actix_web::{ + http::StatusCode, + test::{self, TestRequest}, + App, HttpResponse, + }; + + use super::*; + + #[actix_web::test] + async fn custom_files_listing_renderer() { + let srv = test::init_service( + App::new().service( + Files::new("/", "./tests") + .show_files_listing() + .files_listing_renderer(|dir, req| { + Ok(ServiceResponse::new( + req.clone(), + HttpResponse::Ok().body(dir.path.to_str().unwrap().to_owned()), + )) + }), + ), + ) + .await; + + let req = TestRequest::with_uri("/").to_request(); + let res = test::call_service(&srv, req).await; + + assert_eq!(res.status(), StatusCode::OK); + let body = test::read_body(res).await; + assert!( + body.ends_with(b"actix-files/tests/"), + "body {:?} does not end with `actix-files/tests/`", + body + ); + } +} diff --git a/actix-files/src/lib.rs b/actix-files/src/lib.rs index 40327e5e8..0fbe39a8e 100644 --- a/actix-files/src/lib.rs +++ b/actix-files/src/lib.rs @@ -13,6 +13,7 @@ #![deny(rust_2018_idioms, nonstandard_style)] #![warn(future_incompatible, missing_docs, missing_debug_implementations)] +#![allow(clippy::uninlined_format_args)] use actix_service::boxed::{BoxService, BoxServiceFactory}; use actix_web::{ diff --git a/actix-files/src/path_buf.rs b/actix-files/src/path_buf.rs index 9ee1338c6..650f55247 100644 --- a/actix-files/src/path_buf.rs +++ b/actix-files/src/path_buf.rs @@ -30,7 +30,7 @@ impl PathBufWrap { let mut segment_count = path.matches('/').count() + 1; // we can decode the whole path here (instead of per-segment decoding) - // because we will reject `%2F` in paths using `segement_count`. + // because we will reject `%2F` in paths using `segment_count`. let path = percent_encoding::percent_decode_str(path) .decode_utf8() .map_err(|_| UriSegmentError::NotValidUtf8)?; diff --git a/actix-http-test/CHANGES.md b/actix-http-test/CHANGES.md index 028fe3ddc..e56883c19 100644 --- a/actix-http-test/CHANGES.md +++ b/actix-http-test/CHANGES.md @@ -1,10 +1,13 @@ # Changes ## Unreleased - 2022-xx-xx + +## 3.1.0 - 2023-01-21 + - Minimum supported Rust version (MSRV) is now 1.59. - ## 3.0.0 - 2022-07-24 + - `TestServer::stop` is now async and will wait for the server and system to shutdown. [#2442] - Added `TestServer::client_headers` method. [#2097] - Update `actix-server` dependency to `2`. @@ -16,71 +19,71 @@ [#2097]: https://github.com/actix/actix-web/pull/2097 [#1813]: https://github.com/actix/actix-web/pull/1813 -
3.0.0 Pre-Releases ## 3.0.0-beta.13 - 2022-02-16 + - No significant changes since `3.0.0-beta.12`. - ## 3.0.0-beta.12 - 2022-01-31 + - No significant changes since `3.0.0-beta.11`. - ## 3.0.0-beta.11 - 2022-01-04 + - Minimum supported Rust version (MSRV) is now 1.54. - ## 3.0.0-beta.10 - 2021-12-27 + - Update `actix-server` to `2.0.0-rc.2`. [#2550] [#2550]: https://github.com/actix/actix-web/pull/2550 - ## 3.0.0-beta.9 - 2021-12-11 + - No significant changes since `3.0.0-beta.8`. - ## 3.0.0-beta.8 - 2021-11-30 + - Update `actix-tls` to `3.0.0-rc.1`. [#2474] [#2474]: https://github.com/actix/actix-web/pull/2474 - ## 3.0.0-beta.7 - 2021-11-22 + - Fix compatibility with experimental `io-uring` feature of `actix-rt`. [#2408] [#2408]: https://github.com/actix/actix-web/pull/2408 - ## 3.0.0-beta.6 - 2021-11-15 + - `TestServer::stop` is now async and will wait for the server and system to shutdown. [#2442] - Update `actix-server` to `2.0.0-beta.9`. [#2442] - Minimum supported Rust version (MSRV) is now 1.52. [#2442]: https://github.com/actix/actix-web/pull/2442 - ## 3.0.0-beta.5 - 2021-09-09 + - Minimum supported Rust version (MSRV) is now 1.51. - ## 3.0.0-beta.4 - 2021-04-02 + - Added `TestServer::client_headers` method. [#2097] [#2097]: https://github.com/actix/actix-web/pull/2097 - ## 3.0.0-beta.3 - 2021-03-09 -- No notable changes. +- No notable changes. ## 3.0.0-beta.2 - 2021-02-10 + - No notable changes. - ## 3.0.0-beta.1 - 2021-01-07 + - Update `bytes` to `1.0`. [#1813] [#1813]: https://github.com/actix/actix-web/pull/1813 @@ -88,6 +91,7 @@
## 2.1.0 - 2020-11-25 + - Add ability to set address for `TestServer`. [#1645] - Upgrade `base64` to `0.13`. - Upgrade `serde_urlencoded` to `0.7`. [#1773] @@ -95,12 +99,12 @@ [#1773]: https://github.com/actix/actix-web/pull/1773 [#1645]: https://github.com/actix/actix-web/pull/1645 - ## 2.0.0 - 2020-09-11 + - Update actix-codec and actix-utils dependencies. - ## 2.0.0-alpha.1 - 2020-05-23 + - Update the `time` dependency to 0.2.7 - Update `actix-connect` dependency to 2.0.0-alpha.2 - Make `test_server` `async` fn. @@ -110,55 +114,56 @@ - Update `env_logger` dependency to 0.7 ## 1.0.0 - 2019-12-13 + - Replaced `TestServer::start()` with `test_server()` - ## 1.0.0-alpha.3 - 2019-12-07 + - Migrate to `std::future` - ## 0.2.5 - 2019-09-17 + - Update serde_urlencoded to "0.6.1" - Increase TestServerRuntime timeouts from 500ms to 3000ms - Do not override current `System` - ## 0.2.4 - 2019-07-18 + - Update actix-server to 0.6 - ## 0.2.3 - 2019-07-16 + - Add `delete`, `options`, `patch` methods to `TestServerRunner` - ## 0.2.2 - 2019-06-16 + - Add .put() and .sput() methods - ## 0.2.1 - 2019-06-05 + - Add license files - ## 0.2.0 - 2019-05-12 + - Update awc and actix-http deps - ## 0.1.1 - 2019-04-24 + - Always make new connection for http client - ## 0.1.0 - 2019-04-16 + - No changes - ## 0.1.0-alpha.3 - 2019-04-02 + - Request functions accept path #743 - ## 0.1.0-alpha.2 - 2019-03-29 + - Added TestServerRuntime::load_body() method - Update actix-http and awc libraries - ## 0.1.0-alpha.1 - 2019-03-28 + - Initial impl diff --git a/actix-http-test/Cargo.toml b/actix-http-test/Cargo.toml index 86338fb06..cd5e87162 100644 --- a/actix-http-test/Cargo.toml +++ b/actix-http-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-http-test" -version = "3.0.0" +version = "3.1.0" authors = ["Nikolay Kim "] description = "Various helpers for Actix applications to use during testing" keywords = ["http", "web", "framework", "async", "futures"] @@ -37,7 +37,6 @@ actix-rt = "2.2" actix-server = "2" awc = { version = "3", default-features = false } -base64 = "0.13" bytes = "1" futures-core = { version = "0.3.17", default-features = false } http = "0.2.5" @@ -48,7 +47,7 @@ serde_json = "1.0" slab = "0.4" serde_urlencoded = "0.7" tls-openssl = { version = "0.10.9", package = "openssl", optional = true } -tokio = { version = "1.8.4", features = ["sync"] } +tokio = { version = "1.24.2", features = ["sync"] } [dev-dependencies] actix-web = { version = "4", default-features = false, features = ["cookies"] } diff --git a/actix-http-test/README.md b/actix-http-test/README.md index 25e7c684e..94f0e88a5 100644 --- a/actix-http-test/README.md +++ b/actix-http-test/README.md @@ -3,15 +3,15 @@ > Various helpers for Actix applications to use during testing. [![crates.io](https://img.shields.io/crates/v/actix-http-test?label=latest)](https://crates.io/crates/actix-http-test) -[![Documentation](https://docs.rs/actix-http-test/badge.svg?version=3.0.0)](https://docs.rs/actix-http-test/3.0.0) +[![Documentation](https://docs.rs/actix-http-test/badge.svg?version=3.1.0)](https://docs.rs/actix-http-test/3.1.0) ![Version](https://img.shields.io/badge/rustc-1.59+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-http-test)
-[![Dependency Status](https://deps.rs/crate/actix-http-test/3.0.0/status.svg)](https://deps.rs/crate/actix-http-test/3.0.0) +[![Dependency Status](https://deps.rs/crate/actix-http-test/3.1.0/status.svg)](https://deps.rs/crate/actix-http-test/3.1.0) [![Download](https://img.shields.io/crates/d/actix-http-test.svg)](https://crates.io/crates/actix-http-test) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) ## Documentation & Resources - [API Documentation](https://docs.rs/actix-http-test) -- Minimum Supported Rust Version (MSRV): 1.54 +- Minimum Supported Rust Version (MSRV): 1.59 diff --git a/actix-http-test/src/lib.rs b/actix-http-test/src/lib.rs index 8636ef9c4..a66f7b486 100644 --- a/actix-http-test/src/lib.rs +++ b/actix-http-test/src/lib.rs @@ -2,6 +2,7 @@ #![deny(rust_2018_idioms, nonstandard_style)] #![warn(future_incompatible)] +#![allow(clippy::uninlined_format_args)] #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] @@ -87,6 +88,7 @@ pub async fn test_server_with_addr>( // notify TestServer that server and system have shut down // all thread managed resources should be dropped at this point + #[allow(clippy::let_underscore_future)] let _ = thread_stop_tx.send(()); }); @@ -294,6 +296,7 @@ impl Drop for TestServer { // without needing to await anything // signal server to stop + #[allow(clippy::let_underscore_future)] let _ = self.server.stop(true); // signal system to stop diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index 045ae461f..033cd994c 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -1,84 +1,123 @@ # Changes ## Unreleased - 2022-xx-xx + +## 3.3.0 - 2023-01-21 + ### Added + +- Implement `MessageBody` for `Cow<'static, str>` and `Cow<'static, [u8]>`. [#2959] - Implement `MessageBody` for `&mut B` where `B: MessageBody + Unpin`. [#2868] - Implement `MessageBody` for `Pin` where `B::Target: MessageBody`. [#2868] +- Automatic h2c detection via new service finalizer `HttpService::tcp_auto_h2c()`. [#2957] +- `HeaderMap::retain()`. [#2955] +- Header name constants in `header` module. [#2956] [#2968] + - `CACHE_STATUS` + - `CDN_CACHE_CONTROL` + - `CROSS_ORIGIN_EMBEDDER_POLICY` + - `CROSS_ORIGIN_OPENER_POLICY` + - `PERMISSIONS_POLICY` + - `X_FORWARDED_FOR` + - `X_FORWARDED_HOST` + - `X_FORWARDED_PROTO` + +### Fixed + +- Fix non-empty body of HTTP/2 HEAD responses. [#2920] ### Performance + - Improve overall performance of operations on `Extensions`. [#2890] +[#2959]: https://github.com/actix/actix-web/pull/2959 [#2868]: https://github.com/actix/actix-web/pull/2868 [#2890]: https://github.com/actix/actix-web/pull/2890 - +[#2920]: https://github.com/actix/actix-web/pull/2920 +[#2957]: https://github.com/actix/actix-web/pull/2957 +[#2955]: https://github.com/actix/actix-web/pull/2955 +[#2956]: https://github.com/actix/actix-web/pull/2956 +[#2968]: https://github.com/actix/actix-web/pull/2968 ## 3.2.2 - 2022-09-11 + ### Changed + - Minimum supported Rust version (MSRV) is now 1.59 due to transitive `time` dependency. ### Fixed + - Avoid possibility of dispatcher getting stuck while back-pressuring I/O. [#2369] [#2369]: https://github.com/actix/actix-web/pull/2369 - ## 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 + ### Changed + - Minimum supported Rust version (MSRV) is now 1.56 due to transitive `hashbrown` dependency. ### Fixed + - Revert broken fix in [#2624] that caused erroneous 500 error responses. Temporarily re-introduces [#2357] bug. [#2779] [#2624]: https://github.com/actix/actix-web/pull/2624 [#2357]: https://github.com/actix/actix-web/issues/2357 [#2779]: https://github.com/actix/actix-web/pull/2779 - ## 3.0.4 - 2022-03-09 + ### Fixed + - Document on docs.rs with `ws` feature enabled. - ## 3.0.3 - 2022-03-08 + ### Fixed + - Allow spaces between header name and colon when parsing responses. [#2684] [#2684]: https://github.com/actix/actix-web/pull/2684 - ## 3.0.2 - 2022-03-05 + ### Fixed + - Fix encoding camel-case header names with more than one hyphen. [#2683] [#2683]: https://github.com/actix/actix-web/pull/2683 - ## 3.0.1 - 2022-03-04 + - Fix panic in H1 dispatcher when pipelining is used with keep-alive. [#2678] [#2678]: https://github.com/actix/actix-web/issues/2678 ## 3.0.0 - 2022-02-25 + ### Dependencies + - Updated `actix-*` to Tokio v1-based versions. [#1813] - Updated `bytes` to `1.0`. [#1813] - Updated `h2` to `0.3`. [#1813] @@ -87,6 +126,7 @@ - Updated `tokio` to `1`. ### Added + - Crate Features: - `ws`; disabled by default. [#2618] - `http2`; disabled by default. [#2618] @@ -155,6 +195,7 @@ - `#[must_use]` for `ws::Codec` to prevent subtle bugs. [#1920] ### Changed + - Traits: - Rename `IntoHeaderValue => TryIntoHeaderValue`. [#2510] - `MessageBody` now has an associated `Error` type. [#2183] @@ -210,6 +251,7 @@ - Minimum supported Rust version (MSRV) is now 1.54. ### Fixed + - A `Vary` header is now correctly sent along with compressed content. [#2501] - HTTP/1.1 dispatcher correctly uses client request timeout. [#2611] - Fixed issue where handlers that took payload but then dropped without reading it to EOF it would cause keep-alive connections to become stuck. [#2624] @@ -222,6 +264,7 @@ - Fixed quality parse error in Accept-Encoding header. [#2344] ### Removed + - Crate Features: - `compress` feature. [#2065] - `cookies` feature. [#2065] @@ -284,7 +327,6 @@ - `downcast` and `downcast_get_type_id` macros. [#2291] - Down-casting for `MessageBody` types; use standard `Any` trait. [#2183] - [#1813]: https://github.com/actix/actix-web/pull/1813 [#1845]: https://github.com/actix/actix-web/pull/1845 [#1857]: https://github.com/actix/actix-web/pull/1857 @@ -357,37 +399,42 @@ [#2660]: https://github.com/actix/actix-web/pull/2660 [00ba8d55]: https://github.com/actix/actix-web/commit/00ba8d55492284581695d824648590715a8bd386 -
3.0.0 Pre-Releases ## 3.0.0-rc.4 - 2022-02-22 + ### Fixed + - Fix h1 dispatcher panic. [1ce58ecb] [1ce58ecb]: https://github.com/actix/actix-web/commit/1ce58ecb305c60e51db06e6c913b7a1344e229ca - ## 3.0.0-rc.3 - 2022-02-16 + - No significant changes since `3.0.0-rc.2`. - ## 3.0.0-rc.2 - 2022-02-08 + ### Added + - Implement `From>` for `Response>`. [#2625] ### Changed + - `error::DispatcherError` enum is now marked `#[non_exhaustive]`. [#2624] ### Fixed + - Issue where handlers that took payload but then dropped without reading it to EOF it would cause keep-alive connections to become stuck. [#2624] [#2624]: https://github.com/actix/actix-web/pull/2624 [#2625]: https://github.com/actix/actix-web/pull/2625 - ## 3.0.0-rc.1 - 2022-01-31 + ### Added + - Implement `Default` for `KeepAlive`. [#2611] - Implement `From` for `KeepAlive`. [#2611] - Implement `From>` for `KeepAlive`. [#2611] @@ -396,6 +443,7 @@ - Crate `http2` feature flag, disabled by default. [#2618] ### Changed + - Rename `ServiceConfig::{client_timer_expire => client_request_deadline}`. [#2611] - Rename `ServiceConfig::{client_disconnect_timer => client_disconnect_deadline}`. [#2611] - Deadline methods in `ServiceConfig` now return `std::time::Instant`s instead of Tokio's wrapper type. [#2611] @@ -406,9 +454,11 @@ - `ServiceConfig::keep_alive` now returns a `KeepAlive`. [#2611] ### Fixed + - HTTP/1.1 dispatcher correctly uses client request timeout. [#2611] ### Removed + - `ServiceConfig::{client_timer, keep_alive_timer}`. [#2611] - `impl From for KeepAlive`; use `Duration`s instead. [#2611] - `impl From> for KeepAlive`; use `Duration`s instead. [#2611] @@ -417,16 +467,19 @@ [#2611]: https://github.com/actix/actix-web/pull/2611 [#2618]: https://github.com/actix/actix-web/pull/2618 - ## 3.0.0-beta.19 - 2022-01-21 + ### Added + - Response headers can be sent as camel case using `res.head_mut().set_camel_case_headers(true)`. [#2587] - `ResponseHead` now implements `Clone`. [#2585] ### Changed + - Brotli (de)compression support is now provided by the `brotli` crate. [#2538] ### Removed + - `ResponseHead::extensions[_mut]()`. [#2585] - `ResponseBuilder::extensions[_mut]()`. [#2585] @@ -434,9 +487,10 @@ [#2585]: https://github.com/actix/actix-web/pull/2585 [#2587]: https://github.com/actix/actix-web/pull/2587 - ## 3.0.0-beta.18 - 2022-01-04 + ### Added + - `impl Eq` for `header::ContentEncoding`. [#2501] - `impl Copy` for `QualityItem` where `T: Copy`. [#2501] - `Quality::ZERO` equivalent to `q=0`. [#2501] @@ -444,6 +498,7 @@ - `ContentEncoding::to_header_value()`. [#2501] ### Changed + - `Quality::MIN` is now the smallest non-zero value. [#2501] - `QualityItem::min` semantics changed with `QualityItem::MIN`. [#2501] - Rename `ContentEncoding::{Br => Brotli}`. [#2501] @@ -451,19 +506,22 @@ - Minimum supported Rust version (MSRV) is now 1.54. ### Fixed + - `ContentEncoding::Identity` can now be parsed from a string. [#2501] - A `Vary` header is now correctly sent along with compressed content. [#2501] ### Removed + - `ContentEncoding::Auto` variant. [#2501] - `ContentEncoding::is_compression()`. [#2501] [#2501]: https://github.com/actix/actix-web/pull/2501 [#2565]: https://github.com/actix/actix-web/pull/2565 - ## 3.0.0-beta.17 - 2021-12-27 + ### Changed + - `HeaderMap::get_all` now returns a `std::slice::Iter`. [#2527] - `Payload` inner fields are now named. [#2545] - `impl Stream` for `Payload` no longer requires the `Stream` variant be `Unpin`. [#2545] @@ -472,30 +530,35 @@ - Rename `PayloadStream` to `BoxedPayloadStream`. [#2545] ### Removed + - `h1::Payload::readany`. [#2545] [#2527]: https://github.com/actix/actix-web/pull/2527 [#2545]: https://github.com/actix/actix-web/pull/2545 - ## 3.0.0-beta.16 - 2021-12-17 + ### Added + - New method on `MessageBody` trait, `try_into_bytes`, with default implementation, for optimizations on body types that complete in exactly one poll. Replaces `is_complete_body` and `take_complete_body`. [#2522] ### Changed + - Rename trait `IntoHeaderPair => TryIntoHeaderPair`. [#2510] - Rename `TryIntoHeaderPair::{try_into_header_pair => try_into_pair}`. [#2510] - Rename trait `IntoHeaderValue => TryIntoHeaderValue`. [#2510] ### Removed + - `MessageBody::{is_complete_body,take_complete_body}`. [#2522] [#2510]: https://github.com/actix/actix-web/pull/2510 [#2522]: https://github.com/actix/actix-web/pull/2522 - ## 3.0.0-beta.15 - 2021-12-11 + ### Added + - Add timeout for canceling HTTP/2 server side connection handshake. Default to 5 seconds. [#2483] - HTTP/2 handshake timeout can be configured with `ServiceConfig::client_timeout`. [#2483] - `Response::map_into_boxed_body`. [#2468] @@ -516,6 +579,7 @@ - New `boxed` method on `MessageBody` trait for wrapping body type. [#2520] ### Changed + - Rename `body::BoxBody::{from_body => new}`. [#2468] - Body type for `Responses` returned from `Response::{new, ok, etc...}` is now `BoxBody`. [#2468] - The `Error` associated type on `MessageBody` type now requires `impl Error` (or similar). [#2468] @@ -525,6 +589,7 @@ - `ResponseBuilder::finish()` now returns `Response>`. [#2468] ### Removed + - `ResponseBuilder::streaming`. [#2468] - `impl Future` for `ResponseBuilder`. [#2468] - Remove unnecessary `MessageBody` bound on types passed to `body::AnyBody::new`. [#2468] @@ -544,9 +609,10 @@ [#2497]: https://github.com/actix/actix-web/pull/2497 [#2520]: https://github.com/actix/actix-web/pull/2520 - ## 3.0.0-beta.14 - 2021-11-30 + ### Changed + - Guarantee ordering of `header::GetAll` iterator to be same as insertion order. [#2467] - Expose `header::map` module. [#2467] - Implement `ExactSizeIterator` and `FusedIterator` for all `HeaderMap` iterators. [#2470] @@ -556,15 +622,17 @@ [#2470]: https://github.com/actix/actix-web/pull/2470 [#2474]: https://github.com/actix/actix-web/pull/2474 - ## 3.0.0-beta.13 - 2021-11-22 + ### Added + - `body::AnyBody::empty` for quickly creating an empty body. [#2446] - `body::AnyBody::none` for quickly creating a "none" body. [#2456] - `impl Clone` for `body::AnyBody where S: Clone`. [#2448] - `body::AnyBody::into_boxed` for quickly converting to a type-erased, boxed body type. [#2448] ### Changed + - Rename `body::AnyBody::{Message => Body}`. [#2446] - Rename `body::AnyBody::{from_message => new_boxed}`. [#2448] - Rename `body::AnyBody::{from_slice => copy_from_slice}`. [#2448] @@ -573,6 +641,7 @@ - `Encoder::response` now returns `AnyBody>`. [#2448] ### Removed + - `body::AnyBody::Empty`; an empty body can now only be represented as a zero-length `Bytes` variant. [#2446] - `body::BodySize::Empty`; an empty body can now only be represented as a `Sized(0)` variant. [#2446] - `EncoderError::Boxed`; it is no longer required. [#2446] @@ -582,33 +651,38 @@ [#2448]: https://github.com/actix/actix-web/pull/2448 [#2456]: https://github.com/actix/actix-web/pull/2456 - ## 3.0.0-beta.12 - 2021-11-15 + ### Changed + - Update `actix-server` to `2.0.0-beta.9`. [#2442] ### Removed + - `client` module. [#2425] - `trust-dns` feature. [#2425] [#2425]: https://github.com/actix/actix-web/pull/2425 [#2442]: https://github.com/actix/actix-web/pull/2442 - ## 3.0.0-beta.11 - 2021-10-20 + ### Changed + - Updated rustls to v0.20. [#2414] - Minimum supported Rust version (MSRV) is now 1.52. [#2414]: https://github.com/actix/actix-web/pull/2414 - ## 3.0.0-beta.10 - 2021-09-09 + ### Changed + - `ContentEncoding` is now marked `#[non_exhaustive]`. [#2377] - Minimum supported Rust version (MSRV) is now 1.51. ### Fixed + - Remove slice creation pointing to potential uninitialized data on h1 encoder. [#2364] - Remove `Into` bound on `Encoder` body types. [#2375] - Fix quality parse error in Accept-Encoding header. [#2344] @@ -618,25 +692,29 @@ [#2344]: https://github.com/actix/actix-web/pull/2344 [#2377]: https://github.com/actix/actix-web/pull/2377 - ## 3.0.0-beta.9 - 2021-08-09 + ### Fixed + - Potential HTTP request smuggling vulnerabilities. [RUSTSEC-2021-0081](https://github.com/rustsec/advisory-db/pull/977) - ## 3.0.0-beta.8 - 2021-06-26 + ### Changed + - Change compression algorithm features flags. [#2250] ### Removed + - `downcast` and `downcast_get_type_id` macros. [#2291] [#2291]: https://github.com/actix/actix-web/pull/2291 [#2250]: https://github.com/actix/actix-web/pull/2250 - ## 3.0.0-beta.7 - 2021-06-17 + ### Added + - Alias `body::Body` as `body::AnyBody`. [#2215] - `BoxAnyBody`: a boxed message body with boxed errors. [#2183] - Re-export `http` crate's `Error` type as `error::HttpError`. [#2171] @@ -647,6 +725,7 @@ - Add zstd support for `ContentEncoding`. [#2244] ### Changed + - The `MessageBody` trait now has an associated `Error` type. [#2183] - All error trait bounds in server service builders have changed from `Into` to `Into>`. [#2253] - All error trait bounds in message body and stream impls changed from `Into` to `Into>`. [#2253] @@ -657,9 +736,10 @@ - Reduce the level from `error` to `debug` for the log line that is emitted when a `500 Internal Server Error` is built using `HttpResponse::from_error`. [#2201] - `ResponseBuilder::message_body` now returns a `Result`. [#2201] - Remove `Unpin` bound on `ResponseBuilder::streaming`. [#2253] -- `HttpServer::{listen_rustls(), bind_rustls()}` now honor the ALPN protocols in the configuation parameter. [#2226] +- `HttpServer::{listen_rustls(), bind_rustls()}` now honor the ALPN protocols in the configuration parameter. [#2226] ### Removed + - Stop re-exporting `http` crate's `HeaderMap` types in addition to ours. [#2171] - Down-casting for `MessageBody` types. [#2183] - `error::Result` alias. [#2201] @@ -678,21 +758,23 @@ [#2253]: https://github.com/actix/actix-web/pull/2253 [#2244]: https://github.com/actix/actix-web/pull/2244 - - ## 3.0.0-beta.6 - 2021-04-17 + ### Added + - `impl MessageBody for Pin>`. [#2152] - `Response::{ok, bad_request, not_found, internal_server_error}`. [#2159] - Helper `body::to_bytes` for async collecting message body into Bytes. [#2158] ### Changed + - The type parameter of `Response` no longer has a default. [#2152] - The `Message` variant of `body::Body` is now `Pin>`. [#2152] - `BodyStream` and `SizedStream` are no longer restricted to Unpin types. [#2152] - Error enum types are marked `#[non_exhaustive]`. [#2161] ### Removed + - `cookies` feature flag. [#2065] - Top-level `cookies` mod (re-export). [#2065] - `HttpMessage` trait loses the `cookies` and `cookie` methods. [#2065] @@ -711,17 +793,20 @@ [#2158]: https://github.com/actix/actix-web/pull/2158 [#2161]: https://github.com/actix/actix-web/pull/2161 - ## 3.0.0-beta.5 - 2021-04-02 + ### Added + - `client::Connector::handshake_timeout` method for customizing TLS connection handshake timeout. [#2081] - `client::ConnectorService` as `client::Connector::finish` method's return type [#2081] - `client::ConnectionIo` trait alias [#2081] ### Changed + - `client::Connector` type now only have one generic type for `actix_service::Service`. [#2063] ### Removed + - Common typed HTTP headers were moved to actix-web. [2094] - `ResponseError` impl for `actix_utils::timeout::TimeoutError`. [#2127] @@ -730,14 +815,16 @@ [#2094]: https://github.com/actix/actix-web/pull/2094 [#2127]: https://github.com/actix/actix-web/pull/2127 - ## 3.0.0-beta.4 - 2021-03-08 + ### Changed + - Feature `cookies` is now optional and disabled by default. [#1981] - `ws::hash_key` now returns array. [#2035] - `ResponseBuilder::json` now takes `impl Serialize`. [#2052] ### Removed + - Re-export of `futures_channel::oneshot::Canceled` is removed from `error` mod. [#1994] - `ResponseError` impl for `futures_channel::oneshot::Canceled` is removed. [#1994] @@ -746,13 +833,14 @@ [#2035]: https://github.com/actix/actix-web/pull/2035 [#2052]: https://github.com/actix/actix-web/pull/2052 - ## 3.0.0-beta.3 - 2021-02-10 + - No notable changes. - ## 3.0.0-beta.2 - 2021-02-10 + ### Added + - `TryIntoHeaderPair` trait that allows using typed and untyped headers in the same methods. [#1869] - `ResponseBuilder::insert_header` method which allows using typed headers. [#1869] - `ResponseBuilder::append_header` method which allows using typed headers. [#1869] @@ -764,22 +852,21 @@ - `trust-dns` optional feature to enable `trust-dns-resolver` as client dns resolver. [#1969] ### Changed -- `ResponseBuilder::content_type` now takes an `impl TryIntoHeaderValue` to support using typed - `mime` types. [#1894] -- Renamed `TryIntoHeaderValue::{try_into => try_into_value}` to avoid ambiguity with std - `TryInto` trait. [#1894] + +- `ResponseBuilder::content_type` now takes an `impl TryIntoHeaderValue` to support using typed `mime` types. [#1894] +- Renamed `TryIntoHeaderValue::{try_into => try_into_value}` to avoid ambiguity with std `TryInto` trait. [#1894] - `Extensions::insert` returns Option of replaced item. [#1904] - Remove `HttpResponseBuilder::json2()`. [#1903] - Enable `HttpResponseBuilder::json()` to receive data by value and reference. [#1903] - `client::error::ConnectError` Resolver variant contains `Box` type. [#1905] - `client::ConnectorConfig` default timeout changed to 5 seconds. [#1905] -- Simplify `BlockingError` type to a unit struct. It's now only triggered when blocking thread pool - is dead. [#1957] +- Simplify `BlockingError` type to a unit struct. It's now only triggered when blocking thread pool is dead. [#1957] - `HeaderMap::len` now returns number of values instead of number of keys. [#1964] - `HeaderMap::insert` now returns iterator of removed values. [#1964] - `HeaderMap::remove` now returns iterator of removed values. [#1964] ### Removed + - `ResponseBuilder::set`; use `ResponseBuilder::insert_header`. [#1869] - `ResponseBuilder::set_header`; use `ResponseBuilder::insert_header`. [#1869] - `ResponseBuilder::header`; use `ResponseBuilder::append_header`. [#1869] @@ -789,6 +876,7 @@ - `ResponseError` impl for `actix::MailboxError`. [#1969] ### Documentation + - Vastly improve docs and add examples for `HeaderMap`. [#1964] [#1869]: https://github.com/actix/actix-web/pull/1869 @@ -801,12 +889,14 @@ [#1964]: https://github.com/actix/actix-web/pull/1964 [#1969]: https://github.com/actix/actix-web/pull/1969 - ## 3.0.0-beta.1 - 2021-01-07 + ### Added + - Add `Http3` to `Protocol` enum for future compatibility and also mark `#[non_exhaustive]`. ### Changed + - Update `actix-*` dependencies to tokio `1.0` based versions. [#1813] - Bumped `rand` to `0.8`. - Update `bytes` to `1.0`. [#1813] @@ -814,16 +904,11 @@ - The `ws::Message::Text` enum variant now contains a `bytestring::ByteString`. [#1864] ### Removed -- Deprecated `on_connect` methods have been removed. Prefer the new - `on_connect_ext` technique. [#1857] -- Remove `ResponseError` impl for `actix::actors::resolver::ResolverError` - due to deprecate of resolver actor. [#1813] -- Remove `ConnectError::SslHandshakeError` and re-export of `HandshakeError`. - due to the removal of this type from `tokio-openssl` crate. openssl handshake - error would return as `ConnectError::SslError`. [#1813] -- Remove `actix-threadpool` dependency. Use `actix_rt::task::spawn_blocking`. - Due to this change `actix_threadpool::BlockingError` type is moved into - `actix_http::error` module. [#1878] + +- Deprecated `on_connect` methods have been removed. Prefer the new `on_connect_ext` technique. [#1857] +- Remove `ResponseError` impl for `actix::actors::resolver::ResolverError` due to deprecate of resolver actor. [#1813] +- Remove `ConnectError::SslHandshakeError` and re-export of `HandshakeError`. due to the removal of this type from `tokio-openssl` crate. openssl handshake error would return as `ConnectError::SslError`. [#1813] +- Remove `actix-threadpool` dependency. Use `actix_rt::task::spawn_blocking`. Due to this change `actix_threadpool::BlockingError` type is moved into `actix_http::error` module. [#1878] [#1813]: https://github.com/actix/actix-web/pull/1813 [#1857]: https://github.com/actix/actix-web/pull/1857 @@ -832,29 +917,34 @@
- ## 2.2.2 - 2022-01-21 + ### Changed + - Migrate to `brotli` crate. [ad7e3c06] [ad7e3c06]: https://github.com/actix/actix-web/commit/ad7e3c06 - ## 2.2.1 - 2021-08-09 + ### Fixed + - Potential HTTP request smuggling vulnerabilities. [RUSTSEC-2021-0081](https://github.com/rustsec/advisory-db/pull/977) - ## 2.2.0 - 2020-11-25 + ### Added + - HttpResponse builders for 1xx status codes. [#1768] - `Accept::mime_precedence` and `Accept::mime_preference`. [#1793] - `TryFrom` and `TryFrom` for `http::header::Quality`. [#1797] ### Fixed + - Started dropping `transfer-encoding: chunked` and `Content-Length` for 1XX and 204 responses. [#1767] ### Changed + - Upgrade `serde_urlencoded` to `0.7`. [#1773] [#1773]: https://github.com/actix/actix-web/pull/1773 @@ -863,12 +953,14 @@ [#1793]: https://github.com/actix/actix-web/pull/1793 [#1797]: https://github.com/actix/actix-web/pull/1797 - ## 2.1.0 - 2020-10-30 + ### Added + - Added more flexible `on_connect_ext` methods for on-connect handling. [#1754] ### Changed + - Upgrade `base64` to `0.13`. [#1744] - Upgrade `pin-project` to `1.0`. [#1733] - Deprecate `ResponseBuilder::{if_some, if_true}`. [#1760] @@ -878,37 +970,42 @@ [#1733]: https://github.com/actix/actix-web/pull/1733 [#1744]: https://github.com/actix/actix-web/pull/1744 - ## 2.0.0 - 2020-09-11 + - No significant changes from `2.0.0-beta.4`. - ## 2.0.0-beta.4 - 2020-09-09 + ### Changed + - Update actix-codec and actix-utils dependencies. - Update actix-connect and actix-tls dependencies. - ## 2.0.0-beta.3 - 2020-08-14 + ### Fixed + - Memory leak of `client::pool::ConnectorPoolSupport`. [#1626] [#1626]: https://github.com/actix/actix-web/pull/1626 - ## 2.0.0-beta.2 - 2020-07-21 + ### Fixed + - Potential UB in h1 decoder using uninitialized memory. [#1614] ### Changed + - Fix illegal chunked encoding. [#1615] [#1614]: https://github.com/actix/actix-web/pull/1614 [#1615]: https://github.com/actix/actix-web/pull/1615 - ## 2.0.0-beta.1 - 2020-07-11 + ### Changed + - Migrate cookie handling to `cookie` crate. [#1558] - Update `sha-1` to 0.9. [#1586] - Fix leak in client pool. [#1580] @@ -918,278 +1015,319 @@ [#1586]: https://github.com/actix/actix-web/pull/1586 [#1580]: https://github.com/actix/actix-web/pull/1580 - ## 2.0.0-alpha.4 - 2020-05-21 + ### Changed + - Bump minimum supported Rust version to 1.40 -- content_length function is removed, and you can set Content-Length by calling - no_chunking function [#1439] -- `BodySize::Sized64` variant has been removed. `BodySize::Sized` now receives a - `u64` instead of a `usize`. +- content_length function is removed, and you can set Content-Length by calling no_chunking function [#1439] +- `BodySize::Sized64` variant has been removed. `BodySize::Sized` now receives a `u64` instead of a `usize`. - Update `base64` dependency to 0.12 ### Fixed + - Support parsing of `SameSite=None` [#1503] [#1439]: https://github.com/actix/actix-web/pull/1439 [#1503]: https://github.com/actix/actix-web/pull/1503 - ## 2.0.0-alpha.3 - 2020-05-08 + ### Fixed + - Correct spelling of ConnectError::Unresolved [#1487] -- Fix a mistake in the encoding of websocket continuation messages wherein - Item::FirstText and Item::FirstBinary are each encoded as the other. +- Fix a mistake in the encoding of websocket continuation messages wherein Item::FirstText and Item::FirstBinary are each encoded as the other. ### Changed + - Implement `std::error::Error` for our custom errors [#1422] -- Remove `failure` support for `ResponseError` since that crate - will be deprecated in the near future. +- Remove `failure` support for `ResponseError` since that crate will be deprecated in the near future. [#1422]: https://github.com/actix/actix-web/pull/1422 [#1487]: https://github.com/actix/actix-web/pull/1487 - ## 2.0.0-alpha.2 - 2020-03-07 + ### Changed + - Update `actix-connect` and `actix-tls` dependency to 2.0.0-alpha.1. [#1395] -- Change default initial window size and connection window size for HTTP2 to 2MB and 1MB - respectively to improve download speed for awc when downloading large objects. [#1394] -- client::Connector accepts initial_window_size and initial_connection_window_size - HTTP2 configuration. [#1394] +- Change default initial window size and connection window size for HTTP2 to 2MB and 1MB respectively to improve download speed for awc when downloading large objects. [#1394] +- client::Connector accepts initial_window_size and initial_connection_window_size HTTP2 configuration. [#1394] - client::Connector allowing to set max_http_version to limit HTTP version to be used. [#1394] [#1394]: https://github.com/actix/actix-web/pull/1394 [#1395]: https://github.com/actix/actix-web/pull/1395 - ## 2.0.0-alpha.1 - 2020-02-27 + ### Changed + - Update the `time` dependency to 0.2.7. - Moved actors messages support from actix crate, enabled with feature `actors`. -- Breaking change: trait MessageBody requires Unpin and accepting `Pin<&mut Self>` instead of - `&mut self` in the poll_next(). +- Breaking change: trait MessageBody requires Unpin and accepting `Pin<&mut Self>` instead of `&mut self` in the poll_next(). - MessageBody is not implemented for &'static [u8] anymore. ### Fixed + - Allow `SameSite=None` cookies to be sent in a response. - ## 1.0.1 - 2019-12-20 + ### Fixed + - Poll upgrade service's readiness from HTTP service handlers - Replace brotli with brotli2 #1224 - ## 1.0.0 - 2019-12-13 + ### Added + - Add websockets continuation frame support ### Changed + - Replace `flate2-xxx` features with `compress` - ## 1.0.0-alpha.5 - 2019-12-09 + ### Fixed + - Check `Upgrade` service readiness before calling it - Fix buffer remaining capacity calculation ### Changed + - Websockets: Ping and Pong should have binary data #1049 - ## 1.0.0-alpha.4 - 2019-12-08 + ### Added + - Add impl ResponseBuilder for Error ### Changed + - Use rust based brotli compression library ## 1.0.0-alpha.3 - 2019-12-07 + ### Changed + - Migrate to tokio 0.2 - Migrate to `std::future` - ## 0.2.11 - 2019-11-06 + ### Added + - Add support for serde_json::Value to be passed as argument to ResponseBuilder.body() -- Add an additional `filename*` param in the `Content-Disposition` header of - `actix_files::NamedFile` to be more compatible. (#1151) +- Add an additional `filename*` param in the `Content-Disposition` header of `actix_files::NamedFile` to be more compatible. (#1151) - Allow to use `std::convert::Infallible` as `actix_http::error::Error` ### Fixed -- To be compatible with non-English error responses, `ResponseError` rendered with `text/plain; - charset=utf-8` header [#1118] + +- To be compatible with non-English error responses, `ResponseError` rendered with `text/plain; charset=utf-8` header [#1118] [#1878]: https://github.com/actix/actix-web/pull/1878 - ## 0.2.10 - 2019-09-11 + ### Added -- Add support for sending HTTP requests with `Rc` in addition to sending HTTP requests - with `RequestHead` + +- Add support for sending HTTP requests with `Rc` in addition to sending HTTP requests with `RequestHead` ### Fixed + - h2 will use error response #1080 - on_connect result isn't added to request extensions for http2 requests #1009 - ## 0.2.9 - 2019-08-13 + ### Changed + - Dropped the `byteorder`-dependency in favor of `stdlib`-implementation - Update percent-encoding to 2.1 - Update serde_urlencoded to 0.6.1 ### Fixed + - Fixed a panic in the HTTP2 handshake in client HTTP requests (#1031) - ## 0.2.8 - 2019-08-01 + ### Added + - Add `rustls` support - Add `Clone` impl for `HeaderMap` ### Fixed -- awc client panic #1016 -- Invalid response with compression middleware enabled, but compression-related features - disabled #997 +- awc client panic #1016 +- Invalid response with compression middleware enabled, but compression-related features disabled #997 ## 0.2.7 - 2019-07-18 + ### Added + - Add support for downcasting response errors #986 - ## 0.2.6 - 2019-07-17 + ### Changed + - Replace `ClonableService` with local copy - Upgrade `rand` dependency version to 0.7 - ## 0.2.5 - 2019-06-28 + ### Added + - Add `on-connect` callback, `HttpServiceBuilder::on_connect()` #946 ### Changed + - Use `encoding_rs` crate instead of unmaintained `encoding` crate - Add `Copy` and `Clone` impls for `ws::Codec` - ## 0.2.4 - 2019-06-16 + ### Fixed + - Do not compress NoContent (204) responses #918 - ## 0.2.3 - 2019-06-02 + ### Added + - Debug impl for ResponseBuilder - From SizedStream and BodyStream for Body ### Changed + - SizedStream uses u64 - ## 0.2.2 - 2019-05-29 + ### Fixed + - Parse incoming stream before closing stream on disconnect #868 - ## 0.2.1 - 2019-05-25 + ### Fixed + - Handle socket read disconnect - ## 0.2.0 - 2019-05-12 + ### Changed + - Update actix-service to 0.4 - Expect and upgrade services accept `ServerConfig` config. ### Deleted + - `OneRequest` service - ## 0.1.5 - 2019-05-04 + ### Fixed + - Clean up response extensions in response pool #817 - ## 0.1.4 - 2019-04-24 + ### Added + - Allow to render h1 request headers in `Camel-Case` ### Fixed + - Read until eof for http/1.0 responses #771 - ## 0.1.3 - 2019-04-23 + ### Fixed + - Fix http client pool management - Fix http client wait queue management #794 - ## 0.1.2 - 2019-04-23 + ### Fixed + - Fix BorrowMutError panic in client connector #793 - ## 0.1.1 - 2019-04-19 + ### Changed + - Cookie::max_age() accepts value in seconds - Cookie::max_age_time() accepts value in time::Duration - Allow to specify server address for client connector - ## 0.1.0 - 2019-04-16 + ### Added + - Expose peer addr via `Request::peer_addr()` and `RequestHead::peer_addr` ### Changed + - `actix_http::encoding` always available - use trust-dns-resolver 0.11.0 - ## 0.1.0-alpha.5 - 2019-04-12 + ### Added + - Allow to use custom service for upgrade requests - Added `h1::SendResponse` future. ### Changed + - MessageBody::length() renamed to MessageBody::size() for consistency - ws handshake verification functions take RequestHead instead of Request - ## 0.1.0-alpha.4 - 2019-04-08 + ### Added + - Allow to use custom `Expect` handler - Add minimal `std::error::Error` impl for `Error` ### Changed + - Export IntoHeaderValue - Render error and return as response body - Use thread pool for response body compression ### Deleted + - Removed PayloadBuffer - ## 0.1.0-alpha.3 - 2019-04-02 + ### Added + - Warn when an unsealed private cookie isn't valid UTF-8 ### Fixed + - Rust 1.31.0 compatibility - Preallocate read buffer for h1 codec - Detect socket disconnection during protocol selection - ## 0.1.0-alpha.2 - 2019-03-29 + ### Added + - Added ws::Message::Nop, no-op websockets message ### Changed + - Do not use thread pool for decompression if chunk size is smaller than 2048. - ## 0.1.0-alpha.1 - 2019-03-28 + - Initial impl diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index 9f3977f0f..108b2314a 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-http" -version = "3.2.2" +version = "3.3.0" authors = [ "Nikolay Kim ", "Rob Ede ", @@ -61,7 +61,7 @@ actix-codec = "0.5" actix-utils = "3" actix-rt = { version = "2.2", default-features = false } -ahash = "0.7" +ahash = "0.8" bitflags = "1.2" bytes = "1" bytestring = "1" @@ -77,7 +77,7 @@ mime = "0.3" percent-encoding = "2.1" pin-project-lite = "0.2" smallvec = "1.6.1" -tokio = { version = "1.13.1", features = [] } +tokio = { version = "1.24.2", features = [] } tokio-util = { version = "0.7", features = ["io", "codec"] } tracing = { version = "0.1.30", default-features = false, features = ["log"] } @@ -86,7 +86,7 @@ h2 = { version = "0.3.9", optional = true } # websockets local-channel = { version = "0.1", optional = true } -base64 = { version = "0.13", optional = true } +base64 = { version = "0.21", optional = true } rand = { version = "0.8", optional = true } sha1 = { version = "0.10", optional = true } @@ -119,7 +119,7 @@ serde_json = "1.0" static_assertions = "1" tls-openssl = { package = "openssl", version = "0.10.9" } tls-rustls = { package = "rustls", version = "0.20.0" } -tokio = { version = "1.8.4", features = ["net", "rt", "macros"] } +tokio = { version = "1.24.2", features = ["net", "rt", "macros"] } [[example]] name = "ws" diff --git a/actix-http/README.md b/actix-http/README.md index 994cf97c6..aa98f953f 100644 --- a/actix-http/README.md +++ b/actix-http/README.md @@ -3,18 +3,18 @@ > HTTP primitives for the Actix ecosystem. [![crates.io](https://img.shields.io/crates/v/actix-http?label=latest)](https://crates.io/crates/actix-http) -[![Documentation](https://docs.rs/actix-http/badge.svg?version=3.2.2)](https://docs.rs/actix-http/3.2.2) +[![Documentation](https://docs.rs/actix-http/badge.svg?version=3.3.0)](https://docs.rs/actix-http/3.3.0) ![Version](https://img.shields.io/badge/rustc-1.59+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-http.svg)
-[![dependency status](https://deps.rs/crate/actix-http/3.2.2/status.svg)](https://deps.rs/crate/actix-http/3.2.2) +[![dependency status](https://deps.rs/crate/actix-http/3.3.0/status.svg)](https://deps.rs/crate/actix-http/3.3.0) [![Download](https://img.shields.io/crates/d/actix-http.svg)](https://crates.io/crates/actix-http) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) ## Documentation & Resources - [API Documentation](https://docs.rs/actix-http) -- Minimum Supported Rust Version (MSRV): 1.54 +- Minimum Supported Rust Version (MSRV): 1.59 ## Example @@ -49,18 +49,3 @@ async fn main() -> io::Result<()> { .await } ``` - -## License - -This project is licensed under either of - -- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)) -- MIT license ([LICENSE-MIT](LICENSE-MIT) or [http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT)) - -at your option. - -## Code of Conduct - -Contribution to the actix-http crate is organized under the terms of the -Contributor Covenant, the maintainer of actix-http, @fafhrd91, promises to -intervene to uphold that code of conduct. diff --git a/actix-http/benches/quality-value.rs b/actix-http/benches/quality-value.rs index 33ba9c4c8..0ed274ded 100644 --- a/actix-http/benches/quality-value.rs +++ b/actix-http/benches/quality-value.rs @@ -1,3 +1,5 @@ +#![allow(clippy::uninlined_format_args)] + use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; const CODES: &[u16] = &[0, 1000, 201, 800, 550]; diff --git a/actix-http/examples/h2c-detect.rs b/actix-http/examples/h2c-detect.rs new file mode 100644 index 000000000..aa3dd5d31 --- /dev/null +++ b/actix-http/examples/h2c-detect.rs @@ -0,0 +1,29 @@ +//! An example that supports automatic selection of plaintext h1/h2c connections. +//! +//! Notably, both the following commands will work. +//! ```console +//! $ curl --http1.1 'http://localhost:8080/' +//! $ curl --http2-prior-knowledge 'http://localhost:8080/' +//! ``` + +use std::{convert::Infallible, io}; + +use actix_http::{HttpService, Request, Response, StatusCode}; +use actix_server::Server; + +#[tokio::main(flavor = "current_thread")] +async fn main() -> io::Result<()> { + env_logger::init_from_env(env_logger::Env::new().default_filter_or("info")); + + Server::build() + .bind("h2c-detect", ("127.0.0.1", 8080), || { + HttpService::build() + .finish(|_req: Request| async move { + Ok::<_, Infallible>(Response::build(StatusCode::OK).body("Hello!")) + }) + .tcp_auto_h2c() + })? + .workers(2) + .run() + .await +} diff --git a/actix-http/src/body/message_body.rs b/actix-http/src/body/message_body.rs index 0cfaa8653..e274cf8aa 100644 --- a/actix-http/src/body/message_body.rs +++ b/actix-http/src/body/message_body.rs @@ -120,7 +120,7 @@ pub trait MessageBody { } mod foreign_impls { - use std::ops::DerefMut; + use std::{borrow::Cow, ops::DerefMut}; use super::*; @@ -324,6 +324,39 @@ mod foreign_impls { } } + impl MessageBody for Cow<'static, [u8]> { + type Error = Infallible; + + #[inline] + fn size(&self) -> BodySize { + BodySize::Sized(self.len() as u64) + } + + #[inline] + fn poll_next( + self: Pin<&mut Self>, + _cx: &mut Context<'_>, + ) -> Poll>> { + if self.is_empty() { + Poll::Ready(None) + } else { + let bytes = match mem::take(self.get_mut()) { + Cow::Borrowed(b) => Bytes::from_static(b), + Cow::Owned(b) => Bytes::from(b), + }; + Poll::Ready(Some(Ok(bytes))) + } + } + + #[inline] + fn try_into_bytes(self) -> Result { + match self { + Cow::Borrowed(b) => Ok(Bytes::from_static(b)), + Cow::Owned(b) => Ok(Bytes::from(b)), + } + } + } + impl MessageBody for &'static str { type Error = Infallible; @@ -379,6 +412,39 @@ mod foreign_impls { } } + impl MessageBody for Cow<'static, str> { + type Error = Infallible; + + #[inline] + fn size(&self) -> BodySize { + BodySize::Sized(self.len() as u64) + } + + #[inline] + fn poll_next( + self: Pin<&mut Self>, + _cx: &mut Context<'_>, + ) -> Poll>> { + if self.is_empty() { + Poll::Ready(None) + } else { + let bytes = match mem::take(self.get_mut()) { + Cow::Borrowed(s) => Bytes::from_static(s.as_bytes()), + Cow::Owned(s) => Bytes::from(s.into_bytes()), + }; + Poll::Ready(Some(Ok(bytes))) + } + } + + #[inline] + fn try_into_bytes(self) -> Result { + match self { + Cow::Borrowed(s) => Ok(Bytes::from_static(s.as_bytes())), + Cow::Owned(s) => Ok(Bytes::from(s.into_bytes())), + } + } + } + impl MessageBody for bytestring::ByteString { type Error = Infallible; diff --git a/actix-http/src/body/sized_stream.rs b/actix-http/src/body/sized_stream.rs index e5e27b287..08cd81a0d 100644 --- a/actix-http/src/body/sized_stream.rs +++ b/actix-http/src/body/sized_stream.rs @@ -44,7 +44,7 @@ where #[inline] fn size(&self) -> BodySize { - BodySize::Sized(self.size as u64) + BodySize::Sized(self.size) } /// Attempts to pull out the next value of the underlying [`Stream`]. diff --git a/actix-http/src/builder.rs b/actix-http/src/builder.rs index 71b933835..e2693acaf 100644 --- a/actix-http/src/builder.rs +++ b/actix-http/src/builder.rs @@ -186,7 +186,7 @@ where self } - /// Finish service configuration and create a HTTP Service for HTTP/1 protocol. + /// Finish service configuration and create a service for the HTTP/1 protocol. pub fn h1(self, service: F) -> H1Service where B: MessageBody, @@ -209,7 +209,7 @@ where .on_connect_ext(self.on_connect_ext) } - /// Finish service configuration and create a HTTP service for HTTP/2 protocol. + /// Finish service configuration and create a service for the HTTP/2 protocol. #[cfg(feature = "http2")] #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] pub fn h2(self, service: F) -> crate::h2::H2Service diff --git a/actix-http/src/h1/chunked.rs b/actix-http/src/h1/chunked.rs index 4005ed892..fc9081b81 100644 --- a/actix-http/src/h1/chunked.rs +++ b/actix-http/src/h1/chunked.rs @@ -71,7 +71,7 @@ impl ChunkedState { match size.checked_mul(radix) { Some(n) => { - *size = n as u64; + *size = n; *size += rem as u64; Poll::Ready(Ok(ChunkedState::Size)) diff --git a/actix-http/src/h1/dispatcher_tests.rs b/actix-http/src/h1/dispatcher_tests.rs index d39c5bd69..db46cdefc 100644 --- a/actix-http/src/h1/dispatcher_tests.rs +++ b/actix-http/src/h1/dispatcher_tests.rs @@ -932,7 +932,6 @@ fn http_msg(msg: impl AsRef) -> BytesMut { .as_ref() .trim() .split('\n') - .into_iter() .map(|line| [line.trim_start(), "\r"].concat()) .collect::>() .join("\n"); diff --git a/actix-http/src/h1/encoder.rs b/actix-http/src/h1/encoder.rs index 21cfd75c4..abe396ce2 100644 --- a/actix-http/src/h1/encoder.rs +++ b/actix-http/src/h1/encoder.rs @@ -450,7 +450,7 @@ impl TransferEncoding { buf.extend_from_slice(&msg[..len as usize]); - *remaining -= len as u64; + *remaining -= len; Ok(*remaining == 0) } else { Ok(true) diff --git a/actix-http/src/h2/dispatcher.rs b/actix-http/src/h2/dispatcher.rs index 680936f0f..3e618820e 100644 --- a/actix-http/src/h2/dispatcher.rs +++ b/actix-http/src/h2/dispatcher.rs @@ -29,7 +29,7 @@ use crate::{ HeaderName, HeaderValue, CONNECTION, CONTENT_LENGTH, DATE, TRANSFER_ENCODING, UPGRADE, }, service::HttpFlow, - Extensions, OnConnectData, Payload, Request, Response, ResponseHead, + Extensions, Method, OnConnectData, Payload, Request, Response, ResponseHead, }; const CHUNK_SIZE: usize = 16_384; @@ -118,6 +118,7 @@ where let payload = crate::h2::Payload::new(body); let pl = Payload::H2 { payload }; let mut req = Request::with_payload(pl); + let head_req = parts.method == Method::HEAD; let head = req.head_mut(); head.uri = parts.uri; @@ -135,10 +136,10 @@ where actix_rt::spawn(async move { // resolve service call and send response. let res = match fut.await { - Ok(res) => handle_response(res.into(), tx, config).await, + Ok(res) => handle_response(res.into(), tx, config, head_req).await, Err(err) => { let res: Response = err.into(); - handle_response(res, tx, config).await + handle_response(res, tx, config, head_req).await } }; @@ -206,6 +207,7 @@ async fn handle_response( res: Response, mut tx: SendResponse, config: ServiceConfig, + head_req: bool, ) -> Result<(), DispatchError> where B: MessageBody, @@ -215,14 +217,14 @@ where // prepare response. let mut size = body.size(); let res = prepare_response(config, res.head(), &mut size); - let eof = size.is_eof(); + let eof_or_head = size.is_eof() || head_req; // send response head and return on eof. let mut stream = tx - .send_response(res, eof) + .send_response(res, eof_or_head) .map_err(DispatchError::SendResponse)?; - if eof { + if eof_or_head { return Ok(()); } diff --git a/actix-http/src/header/common.rs b/actix-http/src/header/common.rs new file mode 100644 index 000000000..6942dc26a --- /dev/null +++ b/actix-http/src/header/common.rs @@ -0,0 +1,53 @@ +//! Common header names not defined in [`http`]. +//! +//! Any headers added to this file will need to be re-exported from the list at `crate::headers`. + +use http::header::HeaderName; + +/// Response header field that indicates how caches have handled that response and its corresponding +/// request. +/// +/// See [RFC 9211](https://www.rfc-editor.org/rfc/rfc9211) for full semantics. +// TODO(breaking): replace with http's version +pub const CACHE_STATUS: HeaderName = HeaderName::from_static("cache-status"); + +/// Response header field that allows origin servers to control the behavior of CDN caches +/// interposed between them and clients separately from other caches that might handle the response. +/// +/// See [RFC 9213](https://www.rfc-editor.org/rfc/rfc9213) for full semantics. +// TODO(breaking): replace with http's version +pub const CDN_CACHE_CONTROL: HeaderName = HeaderName::from_static("cdn-cache-control"); + +/// Response header that prevents a document from loading any cross-origin resources that don't +/// explicitly grant the document permission (using [CORP] or [CORS]). +/// +/// [CORP]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cross-Origin_Resource_Policy_(CORP) +/// [CORS]: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS +pub const CROSS_ORIGIN_EMBEDDER_POLICY: HeaderName = + HeaderName::from_static("cross-origin-embedder-policy"); + +/// Response header that allows you to ensure a top-level document does not share a browsing context +/// group with cross-origin documents. +pub const CROSS_ORIGIN_OPENER_POLICY: HeaderName = + HeaderName::from_static("cross-origin-opener-policy"); + +/// Response header that conveys a desire that the browser blocks no-cors cross-origin/cross-site +/// requests to the given resource. +pub const CROSS_ORIGIN_RESOURCE_POLICY: HeaderName = + HeaderName::from_static("cross-origin-resource-policy"); + +/// Response header that provides a mechanism to allow and deny the use of browser features in a +/// document or within any `