mirror of https://github.com/fafhrd91/actix-web
Compare commits
10 Commits
d6f642c071
...
d04cf62e2f
| Author | SHA1 | Date |
|---|---|---|
|
|
d04cf62e2f | |
|
|
afd53045d4 | |
|
|
d0b9f46e50 | |
|
|
e04b8d548d | |
|
|
12db2a4d30 | |
|
|
d2a2c15ef1 | |
|
|
9b25a18383 | |
|
|
564b364638 | |
|
|
bb2c6cebfd | |
|
|
0cb453e499 |
|
|
@ -49,7 +49,7 @@ jobs:
|
|||
toolchain: ${{ matrix.version.version }}
|
||||
|
||||
- name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean
|
||||
uses: taiki-e/install-action@28a9d316db64b78a951f3f8587a5d08cc97ad8eb # v2.65.6
|
||||
uses: taiki-e/install-action@cc33365ec7e3350bc47bf935f247582cc6f68344 # v2.65.12
|
||||
with:
|
||||
tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ jobs:
|
|||
uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2
|
||||
|
||||
- name: Install just, cargo-hack
|
||||
uses: taiki-e/install-action@28a9d316db64b78a951f3f8587a5d08cc97ad8eb # v2.65.6
|
||||
uses: taiki-e/install-action@cc33365ec7e3350bc47bf935f247582cc6f68344 # v2.65.12
|
||||
with:
|
||||
tool: just,cargo-hack
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ jobs:
|
|||
toolchain: ${{ matrix.version.version }}
|
||||
|
||||
- name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean
|
||||
uses: taiki-e/install-action@28a9d316db64b78a951f3f8587a5d08cc97ad8eb # v2.65.6
|
||||
uses: taiki-e/install-action@cc33365ec7e3350bc47bf935f247582cc6f68344 # v2.65.12
|
||||
with:
|
||||
tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ jobs:
|
|||
toolchain: nightly
|
||||
|
||||
- name: Install just
|
||||
uses: taiki-e/install-action@28a9d316db64b78a951f3f8587a5d08cc97ad8eb # v2.65.6
|
||||
uses: taiki-e/install-action@cc33365ec7e3350bc47bf935f247582cc6f68344 # v2.65.12
|
||||
with:
|
||||
tool: just
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ jobs:
|
|||
components: llvm-tools
|
||||
|
||||
- name: Install just, cargo-llvm-cov, cargo-nextest
|
||||
uses: taiki-e/install-action@28a9d316db64b78a951f3f8587a5d08cc97ad8eb # v2.65.6
|
||||
uses: taiki-e/install-action@cc33365ec7e3350bc47bf935f247582cc6f68344 # v2.65.12
|
||||
with:
|
||||
tool: just,cargo-llvm-cov,cargo-nextest
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ jobs:
|
|||
run: just test-coverage-codecov
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
|
||||
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
|
||||
with:
|
||||
files: codecov.json
|
||||
fail_ci_if_error: true
|
||||
|
|
|
|||
|
|
@ -77,12 +77,12 @@ jobs:
|
|||
toolchain: ${{ vars.RUST_VERSION_EXTERNAL_TYPES }}
|
||||
|
||||
- name: Install just
|
||||
uses: taiki-e/install-action@28a9d316db64b78a951f3f8587a5d08cc97ad8eb # v2.65.6
|
||||
uses: taiki-e/install-action@cc33365ec7e3350bc47bf935f247582cc6f68344 # v2.65.12
|
||||
with:
|
||||
tool: just
|
||||
|
||||
- name: Install cargo-check-external-types
|
||||
uses: taiki-e/cache-cargo-install-action@7447f04c51f2ba27ca35e7f1e28fab848c5b3ba7 # v2.3.1
|
||||
uses: taiki-e/cache-cargo-install-action@25ef9892608d184944df486ae09ffae168b3cda3 # v3.0.0
|
||||
with:
|
||||
tool: cargo-check-external-types
|
||||
|
||||
|
|
|
|||
|
|
@ -2262,9 +2262,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.103"
|
||||
version = "1.0.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8"
|
||||
checksum = "9695f8df41bb4f3d222c95a67532365f569318332d03d5f3f67f37b20e6ebdf0"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
|
@ -3033,9 +3033,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
|||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.48.0"
|
||||
version = "1.49.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408"
|
||||
checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"libc",
|
||||
|
|
@ -3114,9 +3114,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tokio-stream"
|
||||
version = "0.1.17"
|
||||
version = "0.1.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047"
|
||||
checksum = "32da49809aab5c3bc678af03902d4ccddea2a87d028d86392a4b1560c6906c70"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"pin-project-lite",
|
||||
|
|
@ -3140,9 +3140,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tokio-util"
|
||||
version = "0.7.17"
|
||||
version = "0.7.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2efa149fe76073d6e8fd97ef4f4eca7b67f599660115591483572e406e165594"
|
||||
checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-core",
|
||||
|
|
|
|||
|
|
@ -110,14 +110,22 @@ where
|
|||
|
||||
#[allow(clippy::borrow_interior_mutable_const)]
|
||||
fn call(&self, req: ServiceRequest) -> Self::Future {
|
||||
if req.extensions().get::<Encoding>().is_some() {
|
||||
return Either::left(CompressResponse {
|
||||
fut: self.service.call(req),
|
||||
_phantom: PhantomData,
|
||||
});
|
||||
}
|
||||
|
||||
// negotiate content-encoding
|
||||
let accept_encoding = req.get_header::<AcceptEncoding>();
|
||||
|
||||
let accept_encoding = match accept_encoding {
|
||||
// missing header; fallback to identity
|
||||
None => {
|
||||
req.extensions_mut().insert::<Encoding>(Encoding::identity());
|
||||
|
||||
return Either::left(CompressResponse {
|
||||
encoding: Encoding::identity(),
|
||||
fut: self.service.call(req),
|
||||
_phantom: PhantomData,
|
||||
})
|
||||
|
|
@ -143,11 +151,14 @@ where
|
|||
.map_into_right_body()))
|
||||
}
|
||||
|
||||
Some(encoding) => Either::left(CompressResponse {
|
||||
Some(encoding) => {
|
||||
req.extensions_mut().insert::<Encoding>(encoding);
|
||||
|
||||
Either::left(CompressResponse {
|
||||
fut: self.service.call(req),
|
||||
encoding,
|
||||
_phantom: PhantomData,
|
||||
}),
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -159,7 +170,6 @@ pin_project! {
|
|||
{
|
||||
#[pin]
|
||||
fut: S::Future,
|
||||
encoding: Encoding,
|
||||
_phantom: PhantomData<B>,
|
||||
}
|
||||
}
|
||||
|
|
@ -176,8 +186,19 @@ where
|
|||
|
||||
match ready!(this.fut.poll(cx)) {
|
||||
Ok(resp) => {
|
||||
let enc = match this.encoding {
|
||||
Encoding::Known(enc) => *enc,
|
||||
let request_encoding = resp.request().extensions().get::<Encoding>().cloned();
|
||||
|
||||
let encoding = match request_encoding {
|
||||
Some(enc) => enc.clone(),
|
||||
None => {
|
||||
return Poll::Ready(Ok(resp.map_body(move |head, body| {
|
||||
EitherBody::left(Encoder::response(ContentEncoding::Identity, head, body))
|
||||
})));
|
||||
}
|
||||
};
|
||||
|
||||
let enc = match encoding {
|
||||
Encoding::Known(enc) => enc,
|
||||
Encoding::Unknown(enc) => {
|
||||
unimplemented!("encoding '{enc}' should not be here");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue