Skip to content

Commit

Permalink
Merge branch 'master' into add-dependabot-config
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Jul 19, 2023
2 parents 9d5acbe + db99da5 commit 9d1db63
Show file tree
Hide file tree
Showing 198 changed files with 1,652 additions and 1,511 deletions.
59 changes: 15 additions & 44 deletions .github/workflows/ci-post-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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
25 changes: 8 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ jobs:
- { name: macOS, os: macos-latest, triple: x86_64-apple-darwin }
- { name: Windows, os: windows-latest, triple: x86_64-pc-windows-msvc }
version:
- 1.59.0 # MSRV
- 1.65.0 # MSRV
- stable

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
Expand All @@ -49,17 +49,9 @@ jobs:
- 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: workaround MSRV issues
if: matrix.version != 'stable'
run: |
cargo update -p=zstd-sys --precise=2.0.1+zstd.1.5.2
# - name: workaround MSRV issues
# if: matrix.version != 'stable'
# run: |

- name: check minimal
run: cargo ci-check-min
Expand Down Expand Up @@ -101,7 +93,6 @@ jobs:
run: >
sudo bash -c "ulimit -Sl 512 && ulimit -Hl 512 && PATH=$PATH:/usr/share/rust/.cargo/bin && RUSTUP_TOOLCHAIN=stable cargo test --lib --tests -p=actix-files --all-features"
rustdoc:
name: doc tests
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/clippy-fmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ jobs:
- uses: actions/checkout@v3

- uses: actions-rust-lang/setup-rust-toolchain@v1
with: { toolchain: nightly }
# temp: unpin once https://github.com/rust-lang/rust/issues/113152 is fixed
with: { toolchain: nightly-2023-06-28 }

- uses: taiki-e/cache-cargo-install-action@v1
with: { tool: cargo-public-api }
Expand Down
3 changes: 3 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
group_imports = "StdExternalCrate"
imports_granularity = "Crate"
use_field_init_shorthand = true
2 changes: 2 additions & 0 deletions actix-files/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased - 2023-xx-xx

- Minimum supported Rust version (MSRV) is now 1.65 due to transitive `time` dependency.

## 0.6.3 - 2023-01-21

- XHTML files now use `Content-Disposition: inline` instead of `attachment`. [#2903]
Expand Down
4 changes: 2 additions & 2 deletions actix-files/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-web"
categories = ["asynchronous", "web-programming::http-server"]
license = "MIT OR Apache-2.0"
edition = "2018"
edition = "2021"

[lib]
name = "actix_files"
Expand All @@ -26,7 +26,7 @@ actix-service = "2"
actix-utils = "3"
actix-web = { version = "4", default-features = false }

bitflags = "1"
bitflags = "2"
bytes = "1"
derive_more = "0.99.5"
futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] }
Expand Down
4 changes: 2 additions & 2 deletions actix-files/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![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.3)](https://docs.rs/actix-files/0.6.3)
![Version](https://img.shields.io/badge/rustc-1.59+-ab6000.svg)
![Version](https://img.shields.io/badge/rustc-1.65+-ab6000.svg)
![License](https://img.shields.io/crates/l/actix-files.svg)
<br />
[![dependency status](https://deps.rs/crate/actix-files/0.6.3/status.svg)](https://deps.rs/crate/actix-files/0.6.3)
Expand All @@ -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.59
- Minimum Supported Rust Version (MSRV): 1.65
5 changes: 2 additions & 3 deletions actix-files/src/chunked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
7 changes: 6 additions & 1 deletion actix-files/src/directory.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
21 changes: 10 additions & 11 deletions actix-files/src/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -301,12 +300,8 @@ impl Files {
pub fn default_handler<F, U>(mut self, f: F) -> Self
where
F: IntoServiceFactory<U, ServiceRequest>,
U: ServiceFactory<
ServiceRequest,
Config = (),
Response = ServiceResponse,
Error = Error,
> + 'static,
U: ServiceFactory<ServiceRequest, Config = (), Response = ServiceResponse, Error = Error>
+ 'static,
{
// create and configure default resource
self.default = Rc::new(RefCell::new(Some(Rc::new(boxed::factory(
Expand Down Expand Up @@ -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
);
}
}
35 changes: 16 additions & 19 deletions actix-files/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
#![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},
error::Error,
http::header::DispositionType,
};
use mime_guess::from_ext;
use std::path::Path;

mod chunked;
mod directory;
Expand All @@ -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<ServiceRequest, ServiceResponse, Error>;
type HttpNewService = BoxServiceFactory<(), ServiceRequest, ServiceResponse, Error, ()>;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand All @@ -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!(
Expand Down
Loading

0 comments on commit 9d1db63

Please sign in to comment.