From 9afff97acd15320bbd8b7c426d42a3fd369992c3 Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Wed, 19 Jun 2024 06:49:32 +0200 Subject: [PATCH 1/9] docs: v2.32.0 [skip ci] --- docs/content/download-and-install.md | 104 +++++++++++++-------------- scripts/installer.sh | 2 +- 2 files changed, 53 insertions(+), 53 deletions(-) diff --git a/docs/content/download-and-install.md b/docs/content/download-and-install.md index 42ccd0e2..79cf7642 100644 --- a/docs/content/download-and-install.md +++ b/docs/content/download-and-install.md @@ -1,13 +1,13 @@ # Download and Install -Latest **v2.31.1** release `2024-05-23` ([changelog](https://github.com/static-web-server/static-web-server/releases/tag/v2.31.1), [sha256sum](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-SHA256SUM)) +Latest **v2.32.0** release `2024-06-19` ([changelog](https://github.com/static-web-server/static-web-server/releases/tag/v2.32.0), [sha256sum](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-SHA256SUM)) @@ -115,69 +115,69 @@ Pre-compiled binaries grouped by CPU architectures. ### x86_64 -- [static-web-server-v2.31.1-x86_64-apple-darwin.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-x86_64-apple-darwin.tar.gz)
-**SHA256SUM:** `02de9d929d69bc46d14fd4bcc8bff7f158fdbf714d49d3826dc09d9216e870b2` -- [static-web-server-v2.31.1-x86_64-pc-windows-gnu.zip](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-x86_64-pc-windows-gnu.zip)
-**SHA256SUM:** `2a246d41e584f42c68e0d71eb14564620028e0be664916adf00e7df3957f206d` -- [static-web-server-v2.31.1-x86_64-pc-windows-msvc.zip](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-x86_64-pc-windows-msvc.zip)
-**SHA256SUM:** `e2fb31126829209baaa9ac70c142325990455d3939fe0e5aaf62e18be1164337` -- [static-web-server-v2.31.1-x86_64-unknown-freebsd.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-x86_64-unknown-freebsd.tar.gz)
-**SHA256SUM:** `cb6f8919f816591e5002673885e4a3d0daa12ddd8e82b5f668b8eeae10401eb3` -- [static-web-server-v2.31.1-x86_64-unknown-linux-gnu.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-x86_64-unknown-linux-gnu.tar.gz)
-**SHA256SUM:** `8ddc30d11e35ea59ac97e8e89729c8846d95a581f6c28090decb7459d10ccc3f` -- [static-web-server-v2.31.1-x86_64-unknown-linux-musl.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-x86_64-unknown-linux-musl.tar.gz)
-**SHA256SUM:** `55cfc8ded7cdaa2f43831e42ffe7b723536090cfebf5c86a55101b02a8d75894` -- [static-web-server-v2.31.1-x86_64-unknown-netbsd.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-x86_64-unknown-netbsd.tar.gz)
-**SHA256SUM:** `df47da8e237427bb26cd8a81312ca12e3571ecd2b419589c97e5094b8e376624` -- [static-web-server-v2.31.1-x86_64-unknown-illumos.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-x86_64-unknown-illumos.tar.gz)
-**SHA256SUM:** `655e7bfb9b4e1fe39989ef6f9923d7d8d2d534a82b63a4e51e7e9fe1fb1ccb0f` +- [static-web-server-v2.32.0-x86_64-apple-darwin.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-x86_64-apple-darwin.tar.gz)
+**SHA256SUM:** `2c0112758188207af54f2b160e6be6b1318098ae55ab1f9145e1988ea74d3ed7` +- [static-web-server-v2.32.0-x86_64-pc-windows-gnu.zip](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-x86_64-pc-windows-gnu.zip)
+**SHA256SUM:** `7f4c72515a370f5776c2da982417d9a9ccf21773845b1af8e08c72dfe7f59f62` +- [static-web-server-v2.32.0-x86_64-pc-windows-msvc.zip](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-x86_64-pc-windows-msvc.zip)
+**SHA256SUM:** `fbff273a0040b062e96149d811578d10efd547a386c7aa0a2f19e5462849a874` +- [static-web-server-v2.32.0-x86_64-unknown-freebsd.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-x86_64-unknown-freebsd.tar.gz)
+**SHA256SUM:** `25ce34d5b48d4e69afd832ddd24823eb058d1dabb7e797dd85c03b6f54fd264d` +- [static-web-server-v2.32.0-x86_64-unknown-linux-gnu.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-x86_64-unknown-linux-gnu.tar.gz)
+**SHA256SUM:** `7a24eba311d90281d8e2f441918814cf3d4455c943fd3f2c23d494fc3444aced` +- [static-web-server-v2.32.0-x86_64-unknown-linux-musl.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-x86_64-unknown-linux-musl.tar.gz)
+**SHA256SUM:** `8d6346fb74808e3ec4dee6e80df0ac3d1dd69fc61f46214af4449834b8234a07` +- [static-web-server-v2.32.0-x86_64-unknown-netbsd.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-x86_64-unknown-netbsd.tar.gz)
+**SHA256SUM:** `338b2c685a49858229f1acc97fd078d37e63d808428f031c1b82084c3f229429` +- [static-web-server-v2.32.0-x86_64-unknown-illumos.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-x86_64-unknown-illumos.tar.gz)
+**SHA256SUM:** `d830b506c6cb7313c9a1e382be3cd21d8738719c74df093754a439b69844ff10` ### ARM64 -- [static-web-server-v2.31.1-aarch64-unknown-linux-gnu.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-aarch64-unknown-linux-gnu.tar.gz)
-**SHA256SUM:** `534b8091cc206618d4fb3f6cd0a669e2bbc3d8fab46db096f91b70f373c224f1` -- [static-web-server-v2.31.1-aarch64-unknown-linux-musl.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-aarch64-unknown-linux-musl.tar.gz)
-**SHA256SUM:** `c76fea34b8406297d64062a5e295280dcb871de3f3e9c43a49113a1b5ca5318e` -- [static-web-server-v2.31.1-aarch64-apple-darwin.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-aarch64-apple-darwin.tar.gz)
-**SHA256SUM:** `c0997e43211fc4879afd90485a75c15a902ca86cb536ed6300ee6e27199b1df0` -- [static-web-server-v2.31.1-aarch64-linux-android.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-aarch64-linux-android.tar.gz)
-**SHA256SUM:** `77117ef0553189e79dd90ebd0fe7da123841db105fd058d1553ef85ac2dc55f5` -- [static-web-server-v2.31.1-aarch64-pc-windows-msvc.zip](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-aarch64-pc-windows-msvc.zip)
-**SHA256SUM:** `57af06a0f219d264c43fe2695e3d1b45c041cfde99758d8678dde375313315a5` +- [static-web-server-v2.32.0-aarch64-unknown-linux-gnu.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-aarch64-unknown-linux-gnu.tar.gz)
+**SHA256SUM:** `1544651fa9bb2c04c8c571ea8debf7698df917336b5e703fcc9a779e17f33fdc` +- [static-web-server-v2.32.0-aarch64-unknown-linux-musl.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-aarch64-unknown-linux-musl.tar.gz)
+**SHA256SUM:** `eaa8f79c088707bbfb999de96e4306d3b22d09c6f57a08a279e5aeafaa9b849f` +- [static-web-server-v2.32.0-aarch64-apple-darwin.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-aarch64-apple-darwin.tar.gz)
+**SHA256SUM:** `da6a4779ed2a41a7ebefa29c0eb02370d2f52a23cce7b9eaf37ab4be1b97abe4` +- [static-web-server-v2.32.0-aarch64-linux-android.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-aarch64-linux-android.tar.gz)
+**SHA256SUM:** `abde6c8977498b893d7671b6ed428654979297cfc59d4e088dfb27e3d2654227` +- [static-web-server-v2.32.0-aarch64-pc-windows-msvc.zip](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-aarch64-pc-windows-msvc.zip)
+**SHA256SUM:** `cd06b70f0628457e17a8a3616e174b490023ed1066a105ae135ee65545809e38` ### x86 -- [static-web-server-v2.31.1-i686-pc-windows-msvc.zip](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-i686-pc-windows-msvc.zip)
-**SHA256SUM:** `53e14a56d6c685d68faa51c1515d2ea843209b4aadfacc47e9e099cfba8c88eb` -- [static-web-server-v2.31.1-i686-unknown-freebsd.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-i686-unknown-freebsd.tar.gz)
-**SHA256SUM:** `4b8911fe1dd95685a7ea641f4921333229304e75c60df081ddec6cb3a6525d1b` -- [static-web-server-v2.31.1-i686-unknown-linux-gnu.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-i686-unknown-linux-gnu.tar.gz)
-**SHA256SUM:** `92f16a46996dff4b53dcad8dafe93528f270f711f6daac928c4475a0b6cbe104` -- [static-web-server-v2.31.1-i686-unknown-linux-musl.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-i686-unknown-linux-musl.tar.gz)
-**SHA256SUM:** `4cb102120c4a64105b4c8bd927e429270b035de95fc980113606760c8fd5f7a6` +- [static-web-server-v2.32.0-i686-pc-windows-msvc.zip](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-i686-pc-windows-msvc.zip)
+**SHA256SUM:** `ffb2b7927cfab6bc7a2022c4a0ea7d82c73d5b56bfe833305955ee46d2ed9608` +- [static-web-server-v2.32.0-i686-unknown-freebsd.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-i686-unknown-freebsd.tar.gz)
+**SHA256SUM:** `0c344b167d2e8024142c13c8689075b4c86852479d5359a0f9fb099efe1fac29` +- [static-web-server-v2.32.0-i686-unknown-linux-gnu.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-i686-unknown-linux-gnu.tar.gz)
+**SHA256SUM:** `33e9f2481ce6f70ef2d80b1f2c3f712e05a9036a3720a920217ff77ddf067ab3` +- [static-web-server-v2.32.0-i686-unknown-linux-musl.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-i686-unknown-linux-musl.tar.gz)
+**SHA256SUM:** `e535ec5baf6d459e05abfd2e18b655f95866e5b05c00c3fa816e4f191fd6b3dc` ### ARM -- [static-web-server-v2.31.1-arm-unknown-linux-gnueabihf.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-arm-unknown-linux-gnueabihf.tar.gz)
-**SHA256SUM:** `eb1bcf695f9512dfef5ec14d906e9efad1bb86937ad071a0da0bc8d692648948` -- [static-web-server-v2.31.1-arm-unknown-linux-musleabihf.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-arm-unknown-linux-musleabihf.tar.gz)
-**SHA256SUM:** `60c4349e4fe91dde2439f345cfa868e50714027b152339ebcf16154aebabf21c` -- [static-web-server-v2.31.1-armv7-unknown-linux-musleabihf.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-armv7-unknown-linux-musleabihf.tar.gz)
-**SHA256SUM:** `0aaeae8a6e4244b34540c6fdc2be6ab3120ce54e7f8cac21ba0117c18b78adbc` +- [static-web-server-v2.32.0-arm-unknown-linux-gnueabihf.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-arm-unknown-linux-gnueabihf.tar.gz)
+**SHA256SUM:** `754ba57444461e0f165a234cf0023196ce01bd7d1e9f19446e5f3e9d99746891` +- [static-web-server-v2.32.0-arm-unknown-linux-musleabihf.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-arm-unknown-linux-musleabihf.tar.gz)
+**SHA256SUM:** `997b82085007a3e86ec002f70420784e4271750be582b8f819279bf9e77c98a8` +- [static-web-server-v2.32.0-armv7-unknown-linux-musleabihf.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-armv7-unknown-linux-musleabihf.tar.gz)
+**SHA256SUM:** `2026cc3dc24c19c0c2915312c8df1c8899f128197ee19a92a93c2fdd5b888efd` ### PowerPC -- [static-web-server-v2.31.1-powerpc64le-unknown-linux-gnu.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-powerpc64le-unknown-linux-gnu.tar.gz)
-**SHA256SUM:** `85f400c5bf4a8604d76eafaa16540508f8ec9da8bd39f7136080c5d9b8d0d85e` +- [static-web-server-v2.32.0-powerpc64le-unknown-linux-gnu.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-powerpc64le-unknown-linux-gnu.tar.gz)
+**SHA256SUM:** `bcfdf97a7e0d0b23e4f592af387dda06b1c08a2234a9c6d17ed673d6f2c5b13c` ### S390X -- [static-web-server-v2.31.1-s390x-unknown-linux-gnu.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.31.1/static-web-server-v2.31.1-s390x-unknown-linux-gnu.tar.gz)
-**SHA256SUM:** `ae96c62b12f55c05bf3c500a96bb5fa57146273a4f67f5556c0cbd0ece71ca00` +- [static-web-server-v2.32.0-s390x-unknown-linux-gnu.tar.gz](https://github.com/static-web-server/static-web-server/releases/download/v2.32.0/static-web-server-v2.32.0-s390x-unknown-linux-gnu.tar.gz)
+**SHA256SUM:** `3945675abb6f3023a7ed3b01d50ba71d6c9e3b648e2a1db9715353a30b8eb7bf` ## Source files -- [static-web-server-2.31.1.tar.gz](https://github.com/static-web-server/static-web-server/archive/refs/tags/v2.31.1.tar.gz)
-**SHA256SUM:** `63cae6bd2bce4d36907805ea54a1e40e9af93a9fb72accbce6445589a083febc` -- [static-web-server-2.31.1.zip](https://github.com/static-web-server/static-web-server/archive/refs/tags/v2.31.1.zip)
-**SHA256SUM:** `2189129d1c00a96973f32b583010ccd9df063fcee8d869fa277480e248b52906` +- [static-web-server-2.32.0.tar.gz](https://github.com/static-web-server/static-web-server/archive/refs/tags/v2.32.0.tar.gz)
+**SHA256SUM:** `0ba853ded8ee63f4714be0ac3aee4ca5c7f97596a18a4f2c3ea0ede373f0e76e` +- [static-web-server-2.32.0.zip](https://github.com/static-web-server/static-web-server/archive/refs/tags/v2.32.0.zip)
+**SHA256SUM:** `876597930a20ff296fec15e3be75469d1be16afdebc6825a395f1fa54e69f224` diff --git a/scripts/installer.sh b/scripts/installer.sh index d7f4d598..3f5b636a 100755 --- a/scripts/installer.sh +++ b/scripts/installer.sh @@ -23,7 +23,7 @@ fi set -u # SWS latest version -version=${SWS_INSTALL_VERSION:-"2.31.1"} +version=${SWS_INSTALL_VERSION:-"2.32.0"} # Default directory where SWS will be installed local_bin=${SWS_INSTALL_DIR:-"/usr/local/bin"} From e64076c6c73fe697fa695f95c7046adbd63bfe36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Wed, 19 Jun 2024 23:27:19 +0200 Subject: [PATCH 2/9] refactor: improve typos configuration (#456) * Improve typos configuration * Remove individual username Co-authored-by: Jose Quintana <1700322+joseluisq@users.noreply.github.com> * Ignore all usernames Co-authored-by: Jose Quintana <1700322+joseluisq@users.noreply.github.com> --- .github/workflows/config/typos.toml | 24 ++++++++++++++++++------ CHANGELOG.md | 6 +++--- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.github/workflows/config/typos.toml b/.github/workflows/config/typos.toml index f956a388..dc90c875 100644 --- a/.github/workflows/config/typos.toml +++ b/.github/workflows/config/typos.toml @@ -1,7 +1,19 @@ +[files] +extend-exclude = [ + ".git/", +] +ignore-hidden = false + +[default] +extend-ignore-re = [ + "\\[[0-9a-f]{7}\\]", + "commit/[0-9a-f]{7}", + "\\{a,ba,da,k,z\\}sh", + "\\[@[a-zA-Z0-9\\-]+\\]", +] + [default.extend-words] -Compressable = "Compressable" -ba = "ba" -caf = "caf" -flate = "flate" -Ody = "Ody" -prefered = "prefered" +compressable = "compressable" + +[default.extend-identifiers] +flate2 = "flate2" diff --git a/CHANGELOG.md b/CHANGELOG.md index 662b2d96..0ffea55b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -93,7 +93,7 @@ __Fixes__ __Features__ - [012ef11](https://github.com/static-web-server/static-web-server/commit/012ef11) Crate: Display platforms-specific documentation on docs.rs. -- [a197f20](https://github.com/static-web-server/static-web-server/commit/a197f20) CI: Load testing benchmarks comparison for each commit via Github Actions. PR [#355](https://github.com/static-web-server/static-web-server/pull/355) by [@palant](https://github.com/palant). +- [a197f20](https://github.com/static-web-server/static-web-server/commit/a197f20) CI: Load testing benchmarks comparison for each commit via GitHub Actions. PR [#355](https://github.com/static-web-server/static-web-server/pull/355) by [@palant](https://github.com/palant). __Refactorings__ @@ -660,7 +660,7 @@ __Docs__ **Advice about the new organization change** -Certainly, there is no impact if you still rely on previous Github release links (E.g pre-compiled binaries) because they are always redirected permanently.
+Certainly, there is no impact if you still rely on previous GitHub release links (E.g pre-compiled binaries) because they are always redirected permanently.
However, since we moved to a [new organization](https://github.com/static-web-server/static-web-server), we highly encourage you to update your links using the new GitHub release address of the `static-web-server` organization. ## v2.13.1 - 2022-10-17 @@ -1269,7 +1269,7 @@ __Refactorings__ __Codebase__ -- [7265f6b](https://github.com/static-web-server/static-web-server/commit/7265f6b) Github Actions as new CI. +- [7265f6b](https://github.com/static-web-server/static-web-server/commit/7265f6b) GitHub Actions as new CI. - [c63b549](https://github.com/static-web-server/static-web-server/commit/c63b549) Remove Travis CI. - [65250c0](https://github.com/static-web-server/static-web-server/commit/65250c0) Minor simplications on server module. - [b94fe72](https://github.com/static-web-server/static-web-server/commit/b94fe72) Update core modules structure. From 4c805d626e4b66bd7e1114cf1221ae45eb58647e Mon Sep 17 00:00:00 2001 From: Jose Quintana <1700322+joseluisq@users.noreply.github.com> Date: Thu, 27 Jun 2024 01:35:02 +0200 Subject: [PATCH 3/9] refactor: remove redundant `async` function signatures (#457) --- src/compression_static.rs | 4 ++-- src/control_headers.rs | 12 ++++++------ src/directory_listing.rs | 12 ++++-------- src/https_redirect.rs | 2 +- src/response.rs | 2 +- src/server.rs | 4 +--- src/static_files.rs | 33 ++++++++++++--------------------- tests/cors.rs | 28 ++++++++++++++-------------- tests/settings.rs | 4 ++-- 9 files changed, 43 insertions(+), 58 deletions(-) diff --git a/src/compression_static.rs b/src/compression_static.rs index 032cd823..7a64a916 100644 --- a/src/compression_static.rs +++ b/src/compression_static.rs @@ -54,9 +54,9 @@ pub(crate) fn post_process( } /// Search for the pre-compressed variant of the given file path. -pub async fn precompressed_variant<'a>( +pub fn precompressed_variant( file_path: &Path, - headers: &'a HeaderMap, + headers: &HeaderMap, ) -> Option { tracing::trace!( "preparing pre-compressed file variant path of {}", diff --git a/src/control_headers.rs b/src/control_headers.rs index 6f0169c3..231ca124 100644 --- a/src/control_headers.rs +++ b/src/control_headers.rs @@ -88,8 +88,8 @@ mod tests { MAX_AGE_ONE_DAY, MAX_AGE_ONE_HOUR, MAX_AGE_ONE_YEAR, }; - #[tokio::test] - async fn headers_one_hour() { + #[test] + fn headers_one_hour() { let mut resp = Response::new(Body::empty()); *resp.status_mut() = StatusCode::OK; @@ -105,8 +105,8 @@ mod tests { } } - #[tokio::test] - async fn headers_one_day_default() { + #[test] + fn headers_one_day_default() { let mut resp = Response::new(Body::empty()); *resp.status_mut() = StatusCode::OK; @@ -120,8 +120,8 @@ mod tests { ); } - #[tokio::test] - async fn headers_one_year() { + #[test] + fn headers_one_year() { let mut resp = Response::new(Body::empty()); *resp.status_mut() = StatusCode::OK; diff --git a/src/directory_listing.rs b/src/directory_listing.rs index 5c6d7b7b..485958a6 100644 --- a/src/directory_listing.rs +++ b/src/directory_listing.rs @@ -8,14 +8,12 @@ use chrono::{DateTime, Local, Utc}; use clap::ValueEnum; -use futures_util::{future, future::Either}; use headers::{ContentLength, ContentType, HeaderMapExt}; use hyper::{Body, Method, Response, StatusCode}; use mime_guess::mime; use percent_encoding::{percent_decode_str, percent_encode, AsciiSet, NON_ALPHANUMERIC}; use serde::{Serialize, Serializer}; use std::ffi::{OsStr, OsString}; -use std::future::Future; use std::io; use std::path::Path; @@ -78,9 +76,7 @@ pub fn init(enabled: bool, order: u8, format: DirListFmt, handler_opts: &mut Req /// Provides directory listing support for the current request. /// Note that this function highly depends on `static_files::composed_file_metadata()` function /// which must be called first. See `static_files::handle()` for more details. -pub fn auto_index( - opts: DirListOpts<'_>, -) -> impl Future, StatusCode>> + Send + '_ { +pub fn auto_index(opts: DirListOpts<'_>) -> Result, StatusCode> { // Note: it's safe to call `parent()` here since `filepath` // value always refer to a path with file ending and under // a root directory boundary. @@ -90,7 +86,7 @@ pub fn auto_index( let parent = filepath.parent().unwrap_or(filepath); match std::fs::read_dir(parent) { - Ok(dir_reader) => Either::Left(async move { + Ok(dir_reader) => { let dir_opts = DirEntryOpts { dir_reader, base_path: opts.current_path, @@ -108,7 +104,7 @@ pub fn auto_index( Err(StatusCode::INTERNAL_SERVER_ERROR) } } - }), + } Err(err) => { let status = match err.kind() { io::ErrorKind::NotFound => { @@ -136,7 +132,7 @@ pub fn auto_index( StatusCode::INTERNAL_SERVER_ERROR } }; - Either::Right(future::err(status)) + Err(status) } } } diff --git a/src/https_redirect.rs b/src/https_redirect.rs index 1e9e4a57..94318779 100644 --- a/src/https_redirect.rs +++ b/src/https_redirect.rs @@ -23,7 +23,7 @@ pub struct RedirectOpts { } /// It redirects all requests from HTTP to HTTPS. -pub async fn redirect_to_https( +pub fn redirect_to_https( req: &Request, opts: Arc, ) -> Result, StatusCode> { diff --git a/src/response.rs b/src/response.rs index 7f2cdcae..fda95e4c 100644 --- a/src/response.rs +++ b/src/response.rs @@ -20,7 +20,7 @@ use crate::fs::stream::{optimal_buf_size, FileStream}; /// It converts a file object into a corresponding HTTP response or /// returns an error holding an HTTP status code otherwise. -pub(crate) async fn response_body( +pub(crate) fn response_body( mut file: File, path: &PathBuf, meta: &Metadata, diff --git a/src/server.rs b/src/server.rs index fc7788c1..7ea53f29 100644 --- a/src/server.rs +++ b/src/server.rs @@ -507,9 +507,7 @@ impl Server { async move { let uri = req.uri(); let method = req.method(); - match https_redirect::redirect_to_https(&req, redirect_opts) - .await - { + match https_redirect::redirect_to_https(&req, redirect_opts) { Ok(resp) => Ok(resp), Err(status) => error_page::error_response( uri, method, &status, &page404, &page50x, diff --git a/src/static_files.rs b/src/static_files.rs index 2dd2c6fa..a72fc7ac 100644 --- a/src/static_files.rs +++ b/src/static_files.rs @@ -9,10 +9,6 @@ // Part of the file is borrowed and adapted at a convenience from // https://github.com/seanmonstar/warp/blob/master/src/filters/fs.rs -use futures_util::{ - future, - future::{Either, Future}, -}; use headers::{AcceptRanges, HeaderMap, HeaderMapExt, HeaderValue}; use hyper::{header::CONTENT_ENCODING, header::CONTENT_LENGTH, Body, Method, Response, StatusCode}; use std::fs::{File, Metadata}; @@ -113,8 +109,7 @@ pub async fn handle<'a>(opts: &HandleOpts<'a>) -> Result