diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 000000000..1a54090f0
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,12 @@
+version: 2
+updates:
+ - package-ecosystem: "cargo"
+ directory: "/"
+ schedule:
+ interval: "monthly"
+ open-pull-requests-limit: 10
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "monthly"
+ open-pull-requests-limit: 10
diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml
index 8dd941e04..d293fea95 100644
--- a/.github/workflows/ci-post-merge.yml
+++ b/.github/workflows/ci-post-merge.yml
@@ -26,39 +26,26 @@ jobs:
name: ${{ matrix.target.name }} / ${{ matrix.version }}
runs-on: ${{ matrix.target.os }}
- env:
- CI: 1
- CARGO_INCREMENTAL: 0
- VCPKGRS_DYNAMIC: 1
- CARGO_UNSTABLE_SPARSE_REGISTRY: true
-
steps:
- uses: actions/checkout@v3
- # install OpenSSL on Windows
- # TODO: GitHub actions docs state that OpenSSL is
- # already installed on these Windows machines somewhere
- - name: Set vcpkg root
- if: matrix.target.triple == 'x86_64-pc-windows-msvc'
- run: echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Install OpenSSL
- if: matrix.target.triple == 'x86_64-pc-windows-msvc'
- run: vcpkg install openssl:x64-windows
-
- - name: Install ${{ matrix.version }}
+ if: matrix.target.os == 'windows-latest'
+ run: choco install openssl -y --forcex64 --no-progress
+ - name: Set OpenSSL dir in env
+ if: matrix.target.os == 'windows-latest'
run: |
- rustup set profile minimal
- rustup install ${{ matrix.version }}
- rustup override set ${{ matrix.version }}
+ echo 'OPENSSL_DIR=C:\Program Files\OpenSSL-Win64' | Out-File -FilePath $env:GITHUB_ENV -Append
+ echo 'OPENSSL_DIR=C:\Program Files\OpenSSL' | Out-File -FilePath $env:GITHUB_ENV -Append
+
+ - name: Install Rust (${{ matrix.version }})
+ uses: actions-rust-lang/setup-rust-toolchain@v1
+ with:
+ toolchain: ${{ matrix.version }}
- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack
- - name: Generate Cargo.lock
- run: cargo generate-lockfile
- - name: Cache Dependencies
- uses: Swatinem/rust-cache@v2.2.1
-
- name: check minimal
run: cargo ci-check-min
@@ -88,23 +75,15 @@ jobs:
name: Verify Feature Combinations
runs-on: ubuntu-latest
- env:
- CI: 1
- CARGO_INCREMENTAL: 0
-
steps:
- uses: actions/checkout@v3
- - uses: dtolnay/rust-toolchain@stable
+ - name: Install Rust
+ uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack
- - name: Generate Cargo.lock
- run: cargo generate-lockfile
- - name: Cache Dependencies
- uses: Swatinem/rust-cache@v2.2.1
-
- name: check feature combinations
run: cargo ci-check-all-feature-powerset
@@ -115,22 +94,14 @@ jobs:
name: nextest
runs-on: ubuntu-latest
- env:
- CI: 1
- CARGO_INCREMENTAL: 0
-
steps:
- uses: actions/checkout@v3
- - uses: dtolnay/rust-toolchain@stable
+ - name: Install Rust
+ uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install nextest
uses: taiki-e/install-action@nextest
- - name: Generate Cargo.lock
- run: cargo generate-lockfile
- - name: Cache Dependencies
- uses: Swatinem/rust-cache@v2.2.1
-
- name: Test with cargo-nextest
run: cargo nextest run
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 10e80b751..f85548505 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -29,17 +29,17 @@ jobs:
name: ${{ matrix.target.name }} / ${{ matrix.version }}
runs-on: ${{ matrix.target.os }}
- env: {}
-
steps:
- uses: actions/checkout@v3
- name: Install OpenSSL
if: matrix.target.os == 'windows-latest'
- run: choco install openssl
+ run: choco install openssl -y --forcex64 --no-progress
- name: Set OpenSSL dir in env
if: matrix.target.os == 'windows-latest'
- run: echo 'OPENSSL_DIR=C:\Program Files\OpenSSL-Win64' | Out-File -FilePath $env:GITHUB_ENV -Append
+ run: |
+ echo 'OPENSSL_DIR=C:\Program Files\OpenSSL-Win64' | Out-File -FilePath $env:GITHUB_ENV -Append
+ echo 'OPENSSL_DIR=C:\Program Files\OpenSSL' | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Install Rust (${{ matrix.version }})
uses: actions-rust-lang/setup-rust-toolchain@v1
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index d537031c3..42f16450d 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -29,5 +29,6 @@ jobs:
cargo install cargo-tarpaulin --vers "^0.13"
cargo tarpaulin --workspace --features=rustls,openssl --out Xml --verbose
- name: Upload to Codecov
- uses: codecov/codecov-action@v1
- with: { file: cobertura.xml }
+ uses: codecov/codecov-action@v3.1.4
+ with:
+ file: cobertura.xml
diff --git a/.github/workflows/upload-doc.yml b/.github/workflows/upload-doc.yml
index 743e14412..05b81411d 100644
--- a/.github/workflows/upload-doc.yml
+++ b/.github/workflows/upload-doc.yml
@@ -32,7 +32,7 @@ jobs:
run: echo '' > target/doc/index.html
- name: Deploy to GitHub Pages
- uses: JamesIves/github-pages-deploy-action@v4.4.1
+ uses: JamesIves/github-pages-deploy-action@v4.4.3
with:
folder: target/doc
single-commit: true
diff --git a/.rustfmt.toml b/.rustfmt.toml
new file mode 100644
index 000000000..71b9be3ae
--- /dev/null
+++ b/.rustfmt.toml
@@ -0,0 +1,3 @@
+group_imports = "StdExternalCrate"
+imports_granularity = "Crate"
+use_field_init_shorthand = true
diff --git a/actix-files/src/chunked.rs b/actix-files/src/chunked.rs
index 241b4dccb..c6c019038 100644
--- a/actix-files/src/chunked.rs
+++ b/actix-files/src/chunked.rs
@@ -7,11 +7,10 @@ use std::{
};
use actix_web::{error::Error, web::Bytes};
-use futures_core::{ready, Stream};
-use pin_project_lite::pin_project;
-
#[cfg(feature = "experimental-io-uring")]
use bytes::BytesMut;
+use futures_core::{ready, Stream};
+use pin_project_lite::pin_project;
use super::named::File;
diff --git a/actix-files/src/directory.rs b/actix-files/src/directory.rs
index 3af53a31a..6ade424b9 100644
--- a/actix-files/src/directory.rs
+++ b/actix-files/src/directory.rs
@@ -1,4 +1,9 @@
-use std::{fmt::Write, fs::DirEntry, io, path::Path, path::PathBuf};
+use std::{
+ fmt::Write,
+ fs::DirEntry,
+ io,
+ path::{Path, PathBuf},
+};
use actix_web::{dev::ServiceResponse, HttpRequest, HttpResponse};
use percent_encoding::{utf8_percent_encode, CONTROLS};
diff --git a/actix-files/src/files.rs b/actix-files/src/files.rs
index be2a450d2..e34b5f26a 100644
--- a/actix-files/src/files.rs
+++ b/actix-files/src/files.rs
@@ -8,8 +8,7 @@ use std::{
use actix_service::{boxed, IntoServiceFactory, ServiceFactory, ServiceFactoryExt};
use actix_web::{
dev::{
- AppService, HttpServiceFactory, RequestHead, ResourceDef, ServiceRequest,
- ServiceResponse,
+ AppService, HttpServiceFactory, RequestHead, ResourceDef, ServiceRequest, ServiceResponse,
},
error::Error,
guard::Guard,
@@ -301,12 +300,8 @@ impl Files {
pub fn default_handler(mut self, f: F) -> Self
where
F: IntoServiceFactory,
- U: ServiceFactory<
- ServiceRequest,
- Config = (),
- Response = ServiceResponse,
- Error = Error,
- > + 'static,
+ U: ServiceFactory
+ + 'static,
{
// create and configure default resource
self.default = Rc::new(RefCell::new(Some(Rc::new(boxed::factory(
@@ -422,10 +417,14 @@ mod tests {
assert_eq!(res.status(), StatusCode::OK);
let body = test::read_body(res).await;
+ let body_str = std::str::from_utf8(&body).unwrap();
+ let actual_path = Path::new(&body_str);
+ let expected_path = Path::new("actix-files/tests");
assert!(
- body.ends_with(b"actix-files/tests/"),
- "body {:?} does not end with `actix-files/tests/`",
- body
+ actual_path.ends_with(expected_path),
+ "body {:?} does not end with {:?}",
+ actual_path,
+ expected_path
);
}
}
diff --git a/actix-files/src/lib.rs b/actix-files/src/lib.rs
index bed8194c8..1d8609889 100644
--- a/actix-files/src/lib.rs
+++ b/actix-files/src/lib.rs
@@ -18,6 +18,8 @@
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
+use std::path::Path;
+
use actix_service::boxed::{BoxService, BoxServiceFactory};
use actix_web::{
dev::{RequestHead, ServiceRequest, ServiceResponse},
@@ -25,7 +27,6 @@ use actix_web::{
http::header::DispositionType,
};
use mime_guess::from_ext;
-use std::path::Path;
mod chunked;
mod directory;
@@ -37,16 +38,15 @@ mod path_buf;
mod range;
mod service;
-pub use self::chunked::ChunkedReadFile;
-pub use self::directory::Directory;
-pub use self::files::Files;
-pub use self::named::NamedFile;
-pub use self::range::HttpRange;
-pub use self::service::FilesService;
-
-use self::directory::{directory_listing, DirectoryRenderer};
-use self::error::FilesError;
-use self::path_buf::PathBufWrap;
+pub use self::{
+ chunked::ChunkedReadFile, directory::Directory, files::Files, named::NamedFile,
+ range::HttpRange, service::FilesService,
+};
+use self::{
+ directory::{directory_listing, DirectoryRenderer},
+ error::FilesError,
+ path_buf::PathBufWrap,
+};
type HttpService = BoxService;
type HttpNewService = BoxServiceFactory<(), ServiceRequest, ServiceResponse, Error, ()>;
@@ -554,10 +554,9 @@ mod tests {
#[actix_rt::test]
async fn test_static_files_with_spaces() {
- let srv = test::init_service(
- App::new().service(Files::new("/", ".").index_file("Cargo.toml")),
- )
- .await;
+ let srv =
+ test::init_service(App::new().service(Files::new("/", ".").index_file("Cargo.toml")))
+ .await;
let request = TestRequest::get()
.uri("/tests/test%20space.binary")
.to_request();
@@ -667,8 +666,7 @@ mod tests {
#[actix_rt::test]
async fn test_static_files() {
let srv =
- test::init_service(App::new().service(Files::new("/", ".").show_files_listing()))
- .await;
+ test::init_service(App::new().service(Files::new("/", ".").show_files_listing())).await;
let req = TestRequest::with_uri("/missing").to_request();
let resp = test::call_service(&srv, req).await;
@@ -681,8 +679,7 @@ mod tests {
assert_eq!(resp.status(), StatusCode::NOT_FOUND);
let srv =
- test::init_service(App::new().service(Files::new("/", ".").show_files_listing()))
- .await;
+ test::init_service(App::new().service(Files::new("/", ".").show_files_listing())).await;
let req = TestRequest::with_uri("/tests").to_request();
let resp = test::call_service(&srv, req).await;
assert_eq!(
diff --git a/actix-files/src/named.rs b/actix-files/src/named.rs
index c10bc00ed..d7795ba73 100644
--- a/actix-files/src/named.rs
+++ b/actix-files/src/named.rs
@@ -8,13 +8,13 @@ use std::{
use actix_web::{
body::{self, BoxBody, SizedStream},
dev::{
- self, AppService, HttpServiceFactory, ResourceDef, Service, ServiceFactory,
- ServiceRequest, ServiceResponse,
+ self, AppService, HttpServiceFactory, ResourceDef, Service, ServiceFactory, ServiceRequest,
+ ServiceResponse,
},
http::{
header::{
- self, Charset, ContentDisposition, ContentEncoding, DispositionParam,
- DispositionType, ExtendedValue, HeaderValue,
+ self, Charset, ContentDisposition, ContentEncoding, DispositionParam, DispositionType,
+ ExtendedValue, HeaderValue,
},
StatusCode,
},
@@ -85,6 +85,7 @@ pub struct NamedFile {
#[cfg(not(feature = "experimental-io-uring"))]
pub(crate) use std::fs::File;
+
#[cfg(feature = "experimental-io-uring")]
pub(crate) use tokio_uring::fs::File;
@@ -139,8 +140,7 @@ impl NamedFile {
_ => DispositionType::Attachment,
};
- let mut parameters =
- vec![DispositionParam::Filename(String::from(filename.as_ref()))];
+ let mut parameters = vec![DispositionParam::Filename(String::from(filename.as_ref()))];
if !filename.is_ascii() {
parameters.push(DispositionParam::FilenameExt(ExtendedValue {
diff --git a/actix-files/src/range.rs b/actix-files/src/range.rs
index 65c680ede..528911ae0 100644
--- a/actix-files/src/range.rs
+++ b/actix-files/src/range.rs
@@ -48,8 +48,8 @@ impl HttpRange {
/// `header` is HTTP Range header (e.g. `bytes=bytes=0-9`).
/// `size` is full size of response (file).
pub fn parse(header: &str, size: u64) -> Result, ParseRangeErr> {
- let ranges = http_range::HttpRange::parse(header, size)
- .map_err(|err| ParseRangeErr(err.into()))?;
+ let ranges =
+ http_range::HttpRange::parse(header, size).map_err(|err| ParseRangeErr(err.into()))?;
Ok(ranges
.iter()
diff --git a/actix-files/src/service.rs b/actix-files/src/service.rs
index d94fd5850..3d3b36c40 100644
--- a/actix-files/src/service.rs
+++ b/actix-files/src/service.rs
@@ -62,11 +62,7 @@ impl FilesService {
}
}
- fn serve_named_file(
- &self,
- req: ServiceRequest,
- mut named_file: NamedFile,
- ) -> ServiceResponse {
+ fn serve_named_file(&self, req: ServiceRequest, mut named_file: NamedFile) -> ServiceResponse {
if let Some(ref mime_override) = self.mime_override {
let new_disposition = mime_override(&named_file.content_type.type_());
named_file.content_disposition.disposition = new_disposition;
@@ -120,13 +116,11 @@ impl Service for FilesService {
));
}
- let path_on_disk = match PathBufWrap::parse_path(
- req.match_info().unprocessed(),
- this.hidden_files,
- ) {
- Ok(item) => item,
- Err(err) => return Ok(req.error_response(err)),
- };
+ let path_on_disk =
+ match PathBufWrap::parse_path(req.match_info().unprocessed(), this.hidden_files) {
+ Ok(item) => item,
+ Err(err) => return Ok(req.error_response(err)),
+ };
if let Some(filter) = &this.path_filter {
if !filter(path_on_disk.as_ref(), req.head()) {
@@ -177,8 +171,7 @@ impl Service for FilesService {
match NamedFile::open_async(&path).await {
Ok(mut named_file) => {
if let Some(ref mime_override) = this.mime_override {
- let new_disposition =
- mime_override(&named_file.content_type.type_());
+ let new_disposition = mime_override(&named_file.content_type.type_());
named_file.content_disposition.disposition = new_disposition;
}
named_file.flags = this.file_flags;
diff --git a/actix-files/tests/encoding.rs b/actix-files/tests/encoding.rs
index 7aec25ff9..3c8bdb59b 100644
--- a/actix-files/tests/encoding.rs
+++ b/actix-files/tests/encoding.rs
@@ -24,8 +24,7 @@ async fn test_utf8_file_contents() {
// disable UTF-8 attribute
let srv =
- test::init_service(App::new().service(Files::new("/", "./tests").prefer_utf8(false)))
- .await;
+ test::init_service(App::new().service(Files::new("/", "./tests").prefer_utf8(false))).await;
let req = TestRequest::with_uri("/utf8.txt").to_request();
let res = test::call_service(&srv, req).await;
diff --git a/actix-files/tests/guard.rs b/actix-files/tests/guard.rs
index d053f3fdc..5a97f75d6 100644
--- a/actix-files/tests/guard.rs
+++ b/actix-files/tests/guard.rs
@@ -12,9 +12,7 @@ async fn test_guard_filter() {
let srv = test::init_service(
App::new()
.service(Files::new("/", "./tests/fixtures/guards/first").guard(Host("first.com")))
- .service(
- Files::new("/", "./tests/fixtures/guards/second").guard(Host("second.com")),
- ),
+ .service(Files::new("/", "./tests/fixtures/guards/second").guard(Host("second.com"))),
)
.await;
diff --git a/actix-files/tests/traversal.rs b/actix-files/tests/traversal.rs
index c890b3fe4..4eecb8dde 100644
--- a/actix-files/tests/traversal.rs
+++ b/actix-files/tests/traversal.rs
@@ -9,8 +9,7 @@ use actix_web::{
async fn test_directory_traversal_prevention() {
let srv = test::init_service(App::new().service(Files::new("/", "./tests"))).await;
- let req =
- TestRequest::with_uri("/../../../../../../../../../../../etc/passwd").to_request();
+ let req = TestRequest::with_uri("/../../../../../../../../../../../etc/passwd").to_request();
let res = test::call_service(&srv, req).await;
assert_eq!(res.status(), StatusCode::NOT_FOUND);
diff --git a/actix-http/examples/hello-world.rs b/actix-http/examples/hello-world.rs
index c749cdd00..cf10beddf 100644
--- a/actix-http/examples/hello-world.rs
+++ b/actix-http/examples/hello-world.rs
@@ -23,10 +23,7 @@ async fn main() -> io::Result<()> {
res.insert_header(("x-head", HeaderValue::from_static("dummy value!")));
let forty_two = req.conn_data::().unwrap().to_string();
- res.insert_header((
- "x-forty-two",
- HeaderValue::from_str(&forty_two).unwrap(),
- ));
+ res.insert_header(("x-forty-two", HeaderValue::from_str(&forty_two).unwrap()));
Ok::<_, Infallible>(res.body("Hello world!"))
})
diff --git a/actix-http/src/body/boxed.rs b/actix-http/src/body/boxed.rs
index 2bbb75369..0151ff3a5 100644
--- a/actix-http/src/body/boxed.rs
+++ b/actix-http/src/body/boxed.rs
@@ -77,12 +77,8 @@ impl MessageBody for BoxBody {
cx: &mut Context<'_>,
) -> Poll