diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 59cf43a..dbc9a46 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,91 +1,150 @@ name: CI +env: + CARGO_TERM_COLOR: always + RUST_TOOLCHAIN: nightly-2023-07-08 + on: push: branches: - - master + - master pull_request: {} -env: - RUST_TOOLCHAIN: nightly-2023-07-08 - jobs: - check-nightly: - # Run `cargo check` first to ensure that the pushed code at least compiles. + check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@master - - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{env.RUST_TOOLCHAIN}} - profile: minimal - override: true - - name: Check - uses: actions-rs/cargo@v1 - with: - command: check - args: --workspace --all-features --all-targets + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{env.RUST_TOOLCHAIN}} + override: true + profile: minimal + components: clippy, rustfmt + - uses: Swatinem/rust-cache@v2 + - name: check + run: | + cargo check --all --all-targets --all-features + - name: clippy + run: | + cargo clippy --all --all-targets --all-features + - name: rustfmt + run: | + cargo fmt --all -- --check check-docs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@master - - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{env.RUST_TOOLCHAIN}} - profile: minimal - - name: cargo doc - env: - RUSTDOCFLAGS: "-D rustdoc::broken_intra_doc_links" - run: cargo doc --all-features --no-deps + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{env.RUST_TOOLCHAIN}} + override: true + profile: minimal + - uses: Swatinem/rust-cache@v1 + - name: cargo doc + env: + RUSTDOCFLAGS: "-D broken-intra-doc-links" + run: cargo doc --all-features --no-deps + + test: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{env.RUST_TOOLCHAIN}} + override: true + profile: minimal + - uses: Swatinem/rust-cache@v1 + - name: Run tests + uses: actions-rs/cargo@v1 + with: + command: test + args: --all-features + + test-docs: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{env.RUST_TOOLCHAIN}} + override: true + profile: minimal + - uses: Swatinem/rust-cache@v1 + - name: Run doc tests + uses: actions-rs/cargo@v1 + with: + command: test + args: --all-features --doc + + test-examples: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{env.RUST_TOOLCHAIN}} + override: true + profile: minimal + - uses: Swatinem/rust-cache@v1 + - name: Run doc tests + uses: actions-rs/cargo@v1 + with: + command: test + args: --all-features --examples cargo-hack: + needs: check runs-on: ubuntu-latest steps: - - uses: actions/checkout@master - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - - name: install cargo-hack - uses: taiki-e/install-action@cargo-hack - - name: cargo hack check - run: cargo hack check --each-feature --no-dev-deps --workspace + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{env.RUST_TOOLCHAIN}} + profile: minimal + - name: install cargo-hack + uses: taiki-e/install-action@cargo-hack + - name: cargo hack check + run: cargo hack check --each-feature --no-dev-deps --workspace - test: - needs: check-nightly + dependencies-are-sorted: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{env.RUST_TOOLCHAIN}} + override: true + profile: minimal + - uses: Swatinem/rust-cache@v2 + - name: Install cargo-sort + run: | + cargo install cargo-sort + - name: Check dependency tables + working-directory: . + run: | + cargo sort --workspace --grouped --check + + cargo-deny: + needs: check runs-on: ubuntu-latest - strategy: - # Disable fail-fast. If the test run for a particular Rust version fails, - # don't cancel the other test runs, so that we can determine whether a - # failure only occurs on a particular version. - fail-fast: false steps: - - uses: actions/checkout@master - - name: "install Rust" - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{env.RUST_TOOLCHAIN}} - profile: minimal - override: true - - name: Run tests - uses: actions-rs/cargo@v1 - with: - command: test - args: --workspace --all-features + - uses: actions/checkout@v3 + - uses: EmbarkStudios/cargo-deny-action@v1 - style: - needs: check-nightly + semver-checks: + needs: check runs-on: ubuntu-latest steps: - - uses: actions/checkout@master - - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{env.RUST_TOOLCHAIN}} - components: rustfmt - profile: minimal - - name: rustfmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check + - name: Checkout + uses: actions/checkout@v3 + - name: Check semver + uses: obi1kenobi/cargo-semver-checks-action@v2 + with: + rust-toolchain: ${{env.RUST_TOOLCHAIN}} diff --git a/Cargo.toml b/Cargo.toml index f47a4b2..e7784f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,8 +2,8 @@ members = [ "tower-async", - "tower-async-http", "tower-async-bridge", + "tower-async-http", "tower-async-layer", "tower-async-service", "tower-async-test", diff --git a/deny.toml b/deny.toml new file mode 100644 index 0000000..c000532 --- /dev/null +++ b/deny.toml @@ -0,0 +1,23 @@ +[advisories] +vulnerability = "deny" +unmaintained = "warn" +notice = "warn" +ignore = [] + +[licenses] +unlicensed = "warn" +allow = [] +deny = [] +copyleft = "warn" +allow-osi-fsf-free = "either" +confidence-threshold = 0.8 + +[bans] +multiple-versions = "warn" +highlight = "all" +skip-tree = [] + +[sources] +unknown-registry = "warn" +unknown-git = "warn" +allow-git = [] diff --git a/tower-async-bridge/Cargo.toml b/tower-async-bridge/Cargo.toml index 6e1c9e7..0412269 100644 --- a/tower-async-bridge/Cargo.toml +++ b/tower-async-bridge/Cargo.toml @@ -28,20 +28,20 @@ full = [ into_async = ["tower/util"] [dependencies] -tower-service = { version = "0.3" } -tower-layer = { version = "0.3" } tower = { version = "0.4", optional = true } -tower-async-service = { version = "0.1", path = "../tower-async-service" } tower-async-layer = { version = "0.1", path = "../tower-async-layer" } +tower-async-service = { version = "0.1", path = "../tower-async-service" } +tower-layer = { version = "0.3" } +tower-service = { version = "0.3" } [dev-dependencies] +futures-core = "0.3" +hyper = { version = "0.14", features = ["full"] } +pin-project-lite = "0.2" tokio = { version = "1.11", features = ["macros", "rt-multi-thread"] } -tokio-test = { version = "0.4" } +tokio-test = { version = "0.4" } tower = { version = "0.4", features = ["full"] } tower-async = { path = "../tower-async", features = ["full"] } -pin-project-lite = "0.2" -futures-core = "0.3" -hyper = { version = "0.14", features = ["full"] } [package.metadata.docs.rs] all-features = true diff --git a/tower-async-http/CHANGELOG.md b/tower-async-http/CHANGELOG.md index 88ce132..6f34587 100644 --- a/tower-async-http/CHANGELOG.md +++ b/tower-async-http/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.1.3 (July 24, 2023) + +## Changed + +- update `http-range-header` from `0.3.0` to `0.4.0` and fix range OOB test from reject to accept; + ## 0.1.2 (July 20, 2023) Sync with original `tower-http` codebase from [`0.4.1`](https://github.com/tower-rs/tower-http/releases/tag/tower-http-0.4.1) diff --git a/tower-async-http/Cargo.toml b/tower-async-http/Cargo.toml index 5ec5a14..b1aa806 100644 --- a/tower-async-http/Cargo.toml +++ b/tower-async-http/Cargo.toml @@ -4,7 +4,7 @@ description = """ Tower Async middleware and utilities for HTTP clients and servers. An "Async Trait" fork from the original Tower Library. """ -version = "0.1.2" +version = "0.1.3" authors = ["Glen De Cauwsemaecker "] edition = "2021" license = "MIT" @@ -27,7 +27,8 @@ tower-async-service = { version = "0.1", path = "../tower-async-service" } # optional dependencies async-compression = { version = "0.4", optional = true, features = ["tokio"] } base64 = { version = "0.21", optional = true } -http-range-header = "0.3.0" +http-range-header = "0.4.0" +httpdate = { version = "1.0", optional = true } iri-string = { version = "0.7.0", optional = true } mime = { version = "0.3.17", optional = true, default_features = false } mime_guess = { version = "2", optional = true, default_features = false } @@ -36,28 +37,27 @@ tokio = { version = "1.6", optional = true, default_features = false } tokio-util = { version = "0.7", optional = true, default_features = false, features = ["io"] } tower-async = { version = "0.1", path = "../tower-async", optional = true } tracing = { version = "0.1", default_features = false, optional = true } -httpdate = { version = "1.0", optional = true } uuid = { version = "1.0", features = ["v4"], optional = true } [dev-dependencies] +axum = { version = "0.6" } +brotli = "3" bytes = "1" +clap = { version = "4.3", features = ["derive"] } flate2 = "1.0" -brotli = "3" futures = "0.3" hyper = { version = "0.14", features = ["full"] } -axum = { version = "0.6" } once_cell = "1" +serde_json = "1.0" tokio = { version = "1", features = ["full"] } tower = { version = "0.4", features = ["util", "make", "timeout"] } tower-async = { path = "../tower-async", features = ["full"] } -tower-async-http = { path = ".", features = ["full"] } tower-async-bridge = { path = "../tower-async-bridge", features = ["full"] } +tower-async-http = { path = ".", features = ["full"] } +tracing = { version = "0.1", default_features = false } tracing-subscriber = "0.3" uuid = { version = "1.0", features = ["v4"] } -serde_json = "1.0" zstd = "0.12" -clap = { version = "4.3", features = ["derive"] } -tracing = { version = "0.1", default_features = false } [features] default = [] diff --git a/tower-async-http/src/services/fs/serve_dir/tests.rs b/tower-async-http/src/services/fs/serve_dir/tests.rs index 7ae69f9..5ef9ae5 100644 --- a/tower-async-http/src/services/fs/serve_dir/tests.rs +++ b/tower-async-http/src/services/fs/serve_dir/tests.rs @@ -480,7 +480,7 @@ async fn read_partial_in_bounds() { } #[tokio::test] -async fn read_partial_rejects_out_of_bounds_range() { +async fn read_partial_accepts_out_of_bounds_range() { let svc = ServeDir::new(".."); let bytes_start_incl = 0; let bytes_end_excl = 9999999; @@ -496,11 +496,15 @@ async fn read_partial_rejects_out_of_bounds_range() { .unwrap(); let res = svc.oneshot(req).await.unwrap(); - assert_eq!(res.status(), StatusCode::RANGE_NOT_SATISFIABLE); + assert_eq!(res.status(), StatusCode::PARTIAL_CONTENT); let file_contents = std::fs::read("../README.md").unwrap(); assert_eq!( res.headers()["content-range"], - &format!("bytes */{}", file_contents.len()) + &format!( + "bytes 0-{}/{}", + file_contents.len() - 1, + file_contents.len() + ) ) } diff --git a/tower-async-layer/Cargo.toml b/tower-async-layer/Cargo.toml index b1ea41d..b13aca8 100644 --- a/tower-async-layer/Cargo.toml +++ b/tower-async-layer/Cargo.toml @@ -22,5 +22,5 @@ edition = "2021" [dependencies] [dev-dependencies] -tower-async-service = { path = "../tower-async-service" } tower-async = { path = "../tower-async", features = ["util"] } +tower-async-service = { path = "../tower-async-service" } diff --git a/tower-async-service/Cargo.toml b/tower-async-service/Cargo.toml index c30d2c3..e108394 100644 --- a/tower-async-service/Cargo.toml +++ b/tower-async-service/Cargo.toml @@ -22,7 +22,7 @@ edition = "2021" [dependencies] [dev-dependencies] +futures = "0.3" http = "0.2" -tower-async-layer = { path = "../tower-async-layer" } tokio = { version = "1", features = ["macros", "time"] } -futures = "0.3" +tower-async-layer = { path = "../tower-async-layer" } diff --git a/tower-async/Cargo.toml b/tower-async/Cargo.toml index a5db9c3..c3f4d64 100644 --- a/tower-async/Cargo.toml +++ b/tower-async/Cargo.toml @@ -52,16 +52,16 @@ futures-util = { version = "0.3", default-features = false, features = ["alloc"] tokio = { version = "1.6", optional = true, features = ["sync"] } [dev-dependencies] -tower-async-test = { path = "../tower-async-test" } futures = "0.3" +http = "0.2" pin-project-lite = "0.2" +quickcheck = "1" tokio = { version = "1.6", features = ["macros", "sync", "test-util", "rt-multi-thread"] } tokio-stream = "0.1" tokio-test = "0.4" +tower-async-test = { path = "../tower-async-test" } tracing = { version = "0.1", default-features = false, features = ["std"] } tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt", "ansi"] } -http = "0.2" -quickcheck = "1" [package.metadata.docs.rs] all-features = true