diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml
index a4b54ca7a..008c33f89 100644
--- a/.github/workflows/bench.yml
+++ b/.github/workflows/bench.yml
@@ -5,6 +5,9 @@ on:
branches:
- master
+permissions:
+ contents: read # to fetch code (actions/checkout)
+
jobs:
check_benchmark:
runs-on: ubuntu-latest
diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml
index 1ee97b591..7ac6388d4 100644
--- a/.github/workflows/ci-post-merge.yml
+++ b/.github/workflows/ci-post-merge.yml
@@ -4,6 +4,9 @@ on:
push:
branches: [master]
+permissions:
+ contents: read # to fetch code (actions/checkout)
+
jobs:
build_and_test_nightly:
strategy:
@@ -92,29 +95,21 @@ jobs:
steps:
- uses: actions/checkout@v2
- - name: Install stable
- uses: actions-rs/toolchain@v1
- with:
- toolchain: stable-x86_64-unknown-linux-gnu
- profile: minimal
- override: true
+ - uses: dtolnay/rust-toolchain@stable
- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: Generate Cargo.lock
- uses: actions-rs/cargo@v1
- with: { command: generate-lockfile }
+ run: cargo generate-lockfile
- name: Cache Dependencies
uses: Swatinem/rust-cache@v1.2.0
- name: check feature combinations
- uses: actions-rs/cargo@v1
- with: { command: ci-check-all-feature-powerset }
-
+ run: cargo ci-check-all-feature-powerset
+
- name: check feature combinations
- uses: actions-rs/cargo@v1
- with: { command: ci-check-all-feature-powerset-linux }
+ run: cargo ci-check-all-feature-powerset-linux
nextest:
name: nextest
@@ -127,24 +122,15 @@ jobs:
steps:
- uses: actions/checkout@v2
- - name: Install Rust
- uses: actions-rs/toolchain@v1
- with:
- toolchain: stable
- profile: minimal
- override: true
+ - uses: dtolnay/rust-toolchain@stable
- name: Install nextest
uses: taiki-e/install-action@nextest
- name: Generate Cargo.lock
- uses: actions-rs/cargo@v1
- with: { command: generate-lockfile }
+ run: cargo generate-lockfile
- name: Cache Dependencies
uses: Swatinem/rust-cache@v1.3.0
- name: Test with cargo-nextest
- uses: actions-rs/cargo@v1
- with:
- command: nextest
- args: run
+ run: cargo nextest run
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index de1e1fe18..421becc63 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -6,6 +6,9 @@ on:
push:
branches: [master]
+permissions:
+ contents: read # to fetch code (actions/checkout)
+
jobs:
build_and_test:
strategy:
@@ -63,6 +66,11 @@ jobs:
- name: Cache Dependencies
uses: Swatinem/rust-cache@v1.2.0
+ - name: workaround MSRV issues
+ if: matrix.version != 'stable'
+ run: |
+ cargo update -p=zstd-sys --precise=2.0.1+zstd.1.5.2
+
- name: check minimal
uses: actions-rs/cargo@v1
with: { command: ci-check-min }
@@ -96,16 +104,10 @@ jobs:
steps:
- uses: actions/checkout@v2
- - name: Install Rust
- uses: actions-rs/toolchain@v1
- with:
- toolchain: stable-x86_64-unknown-linux-gnu
- profile: minimal
- override: true
+ - uses: dtolnay/rust-toolchain@stable
- name: Generate Cargo.lock
- uses: actions-rs/cargo@v1
- with: { command: generate-lockfile }
+ run: cargo generate-lockfile
- name: Cache Dependencies
uses: Swatinem/rust-cache@v1.3.0
@@ -123,20 +125,13 @@ jobs:
steps:
- uses: actions/checkout@v2
- - name: Install Rust (nightly)
- uses: actions-rs/toolchain@v1
- with:
- toolchain: nightly-x86_64-unknown-linux-gnu
- profile: minimal
- override: true
+ - uses: dtolnay/rust-toolchain@nightly
- name: Generate Cargo.lock
- uses: actions-rs/cargo@v1
- with: { command: generate-lockfile }
+ run: cargo generate-lockfile
- name: Cache Dependencies
uses: Swatinem/rust-cache@v1.3.0
- name: doc tests
- uses: actions-rs/cargo@v1
+ run: cargo ci-doctest
timeout-minutes: 60
- with: { command: ci-doctest }
diff --git a/.github/workflows/clippy-fmt.yml b/.github/workflows/clippy-fmt.yml
index bc2cec145..e94c4d1af 100644
--- a/.github/workflows/clippy-fmt.yml
+++ b/.github/workflows/clippy-fmt.yml
@@ -9,54 +9,37 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
-
- - name: Install Rust
- uses: actions-rs/toolchain@v1
- with:
- toolchain: stable
- profile: minimal
- components: rustfmt
- - name: Check with rustfmt
- uses: actions-rs/cargo@v1
- with:
- command: fmt
- args: --all -- --check
+ - uses: dtolnay/rust-toolchain@nightly
+ with: { components: rustfmt }
+ - run: cargo fmt --all -- --check
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- - name: Install Rust
- uses: actions-rs/toolchain@v1
- with:
- toolchain: stable
- profile: minimal
- components: clippy
- override: true
+ - uses: dtolnay/rust-toolchain@stable
+ with: { components: clippy }
- name: Generate Cargo.lock
- uses: actions-rs/cargo@v1
- with: { command: generate-lockfile }
+ run: cargo generate-lockfile
- name: Cache Dependencies
uses: Swatinem/rust-cache@v1.2.0
-
+
- name: Check with Clippy
uses: actions-rs/clippy-check@v1
with:
- token: ${{ secrets.GITHUB_TOKEN }}
args: --workspace --tests --examples --all-features
+ token: ${{ secrets.GITHUB_TOKEN }}
lint-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- - name: Install Rust
- uses: actions-rs/toolchain@v1
- with:
- toolchain: stable
- profile: minimal
- components: rust-docs
+
+ - uses: dtolnay/rust-toolchain@stable
+ with: { components: rust-docs }
+
- name: Check for broken intra-doc links
uses: actions-rs/cargo@v1
env:
diff --git a/.github/workflows/upload-doc.yml b/.github/workflows/upload-doc.yml
index 07f839e34..9aadafafc 100644
--- a/.github/workflows/upload-doc.yml
+++ b/.github/workflows/upload-doc.yml
@@ -4,31 +4,29 @@ on:
push:
branches: [master]
+permissions: {}
jobs:
build:
+ permissions:
+ contents: write # to push changes in repo (jamesives/github-pages-deploy-action)
+
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- - name: Install Rust
- uses: actions-rs/toolchain@v1
- with:
- toolchain: nightly-x86_64-unknown-linux-gnu
- profile: minimal
- override: true
+ - uses: dtolnay/rust-toolchain@nightly
- name: Build Docs
- uses: actions-rs/cargo@v1
- with:
- command: doc
- args: --workspace --all-features --no-deps
+ run: cargo +nightly doc --no-deps --workspace --all-features
+ env:
+ RUSTDOCFLAGS: --cfg=docsrs
- name: Tweak HTML
run: echo '' > target/doc/index.html
- name: Deploy to GitHub Pages
- uses: JamesIves/github-pages-deploy-action@v4.4.0
+ uses: JamesIves/github-pages-deploy-action@v4.4.1
with:
folder: target/doc
single-commit: true
diff --git a/actix-files/Cargo.toml b/actix-files/Cargo.toml
index 33de0e6d9..018acdfb1 100644
--- a/actix-files/Cargo.toml
+++ b/actix-files/Cargo.toml
@@ -3,7 +3,6 @@ name = "actix-files"
version = "0.6.2"
authors = [
"Nikolay Kim ",
- "fakeshadow <24548779@qq.com>",
"Rob Ede ",
]
description = "Static file serving for Actix Web"
diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml
index 30e436160..a8b888ef4 100644
--- a/actix-http/Cargo.toml
+++ b/actix-http/Cargo.toml
@@ -77,6 +77,8 @@ mime = "0.3"
percent-encoding = "2.1"
pin-project-lite = "0.2"
smallvec = "1.6.1"
+tokio = { version = "1.13.1", features = [] }
+tokio-util = { version = "0.7", features = ["io", "codec"] }
tracing = { version = "0.1.30", default-features = false, features = ["log"] }
# http2
diff --git a/actix-http/examples/ws.rs b/actix-http/examples/ws.rs
index c4f0503cd..6af6d5095 100644
--- a/actix-http/examples/ws.rs
+++ b/actix-http/examples/ws.rs
@@ -10,13 +10,13 @@ use std::{
time::Duration,
};
-use actix_codec::Encoder;
use actix_http::{body::BodyStream, error::Error, ws, HttpService, Request, Response};
use actix_rt::time::{interval, Interval};
use actix_server::Server;
use bytes::{Bytes, BytesMut};
use bytestring::ByteString;
use futures_core::{ready, Stream};
+use tokio_util::codec::Encoder;
use tracing::{info, trace};
#[actix_rt::main]
diff --git a/actix-http/src/h1/client.rs b/actix-http/src/h1/client.rs
index 75c88d00c..6a0d531d0 100644
--- a/actix-http/src/h1/client.rs
+++ b/actix-http/src/h1/client.rs
@@ -1,9 +1,9 @@
use std::{fmt, io};
-use actix_codec::{Decoder, Encoder};
use bitflags::bitflags;
use bytes::{Bytes, BytesMut};
use http::{Method, Version};
+use tokio_util::codec::{Decoder, Encoder};
use super::{
decoder::{self, PayloadDecoder, PayloadItem, PayloadType},
diff --git a/actix-http/src/h1/codec.rs b/actix-http/src/h1/codec.rs
index 80afd7455..e11f175c9 100644
--- a/actix-http/src/h1/codec.rs
+++ b/actix-http/src/h1/codec.rs
@@ -1,9 +1,9 @@
use std::{fmt, io};
-use actix_codec::{Decoder, Encoder};
use bitflags::bitflags;
use bytes::BytesMut;
use http::{Method, Version};
+use tokio_util::codec::{Decoder, Encoder};
use super::{
decoder::{self, PayloadDecoder, PayloadItem, PayloadType},
diff --git a/actix-http/src/h1/dispatcher.rs b/actix-http/src/h1/dispatcher.rs
index 81090667d..60660b85b 100644
--- a/actix-http/src/h1/dispatcher.rs
+++ b/actix-http/src/h1/dispatcher.rs
@@ -8,13 +8,15 @@ use std::{
task::{Context, Poll},
};
-use actix_codec::{AsyncRead, AsyncWrite, Decoder as _, Encoder as _, Framed, FramedParts};
+use actix_codec::{Framed, FramedParts};
use actix_rt::time::sleep_until;
use actix_service::Service;
use bitflags::bitflags;
use bytes::{Buf, BytesMut};
use futures_core::ready;
use pin_project_lite::pin_project;
+use tokio::io::{AsyncRead, AsyncWrite};
+use tokio_util::codec::{Decoder as _, Encoder as _};
use tracing::{error, trace};
use crate::{
@@ -1004,7 +1006,7 @@ where
this.read_buf.reserve(HW_BUFFER_SIZE - remaining);
}
- match actix_codec::poll_read_buf(io.as_mut(), cx, this.read_buf) {
+ match tokio_util::io::poll_read_buf(io.as_mut(), cx, this.read_buf) {
Poll::Ready(Ok(n)) => {
this.flags.remove(Flags::FINISHED);
diff --git a/actix-http/src/ws/codec.rs b/actix-http/src/ws/codec.rs
index 4a2e741b6..6a149f9a4 100644
--- a/actix-http/src/ws/codec.rs
+++ b/actix-http/src/ws/codec.rs
@@ -1,7 +1,7 @@
-use actix_codec::{Decoder, Encoder};
use bitflags::bitflags;
use bytes::{Bytes, BytesMut};
use bytestring::ByteString;
+use tokio_util::codec::{Decoder, Encoder};
use tracing::error;
use super::{
diff --git a/actix-http/src/ws/dispatcher.rs b/actix-http/src/ws/dispatcher.rs
index 2f6b2363b..396f1e86c 100644
--- a/actix-http/src/ws/dispatcher.rs
+++ b/actix-http/src/ws/dispatcher.rs
@@ -76,7 +76,9 @@ mod inner {
use pin_project_lite::pin_project;
use tracing::debug;
- use actix_codec::{AsyncRead, AsyncWrite, Decoder, Encoder, Framed};
+ use actix_codec::Framed;
+ use tokio::io::{AsyncRead, AsyncWrite};
+ use tokio_util::codec::{Decoder, Encoder};
use crate::{body::BoxBody, Response};
diff --git a/actix-multipart/Cargo.toml b/actix-multipart/Cargo.toml
index 203315f3e..5d15d37cf 100644
--- a/actix-multipart/Cargo.toml
+++ b/actix-multipart/Cargo.toml
@@ -30,8 +30,8 @@ futures-util = { version = "0.3.7", default-features = false }
httparse = "1.3"
local-waker = "0.1"
log = "0.4"
+memchr = "2.5"
mime = "0.3"
-twoway = "0.2"
serde = "1.0"
serde_plain = "1.0"
serde_json = "1.0"
diff --git a/actix-multipart/src/server.rs b/actix-multipart/src/server.rs
index c3757177f..1d0510039 100644
--- a/actix-multipart/src/server.rs
+++ b/actix-multipart/src/server.rs
@@ -606,7 +606,7 @@ impl InnerField {
}
loop {
- return if let Some(idx) = twoway::find_bytes(&payload.buf[pos..], b"\r") {
+ return if let Some(idx) = memchr::memmem::find(&payload.buf[pos..], b"\r") {
let cur = pos + idx;
// check if we have enough data for boundary detection
@@ -827,7 +827,7 @@ impl PayloadBuffer {
/// Read until specified ending
fn read_until(&mut self, line: &[u8]) -> Result