mirror of https://github.com/fafhrd91/actix-web
Compare commits
4 Commits
d297d4f6d7
...
3fdba57feb
| Author | SHA1 | Date |
|---|---|---|
|
|
3fdba57feb | |
|
|
fe890a73b2 | |
|
|
bb2c6cebfd | |
|
|
0cb453e499 |
|
|
@ -49,7 +49,7 @@ jobs:
|
||||||
toolchain: ${{ matrix.version.version }}
|
toolchain: ${{ matrix.version.version }}
|
||||||
|
|
||||||
- name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean
|
- name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean
|
||||||
uses: taiki-e/install-action@44c6d64aa62cd779e873306675c7a58e86d6d532 # v2.62.49
|
uses: taiki-e/install-action@0be4756f42223b67aa4b7df5effad59010cbf4b9 # v2.62.51
|
||||||
with:
|
with:
|
||||||
tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean
|
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
|
uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2
|
||||||
|
|
||||||
- name: Install just, cargo-hack
|
- name: Install just, cargo-hack
|
||||||
uses: taiki-e/install-action@44c6d64aa62cd779e873306675c7a58e86d6d532 # v2.62.49
|
uses: taiki-e/install-action@0be4756f42223b67aa4b7df5effad59010cbf4b9 # v2.62.51
|
||||||
with:
|
with:
|
||||||
tool: just,cargo-hack
|
tool: just,cargo-hack
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ jobs:
|
||||||
toolchain: ${{ matrix.version.version }}
|
toolchain: ${{ matrix.version.version }}
|
||||||
|
|
||||||
- name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean
|
- name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean
|
||||||
uses: taiki-e/install-action@44c6d64aa62cd779e873306675c7a58e86d6d532 # v2.62.49
|
uses: taiki-e/install-action@0be4756f42223b67aa4b7df5effad59010cbf4b9 # v2.62.51
|
||||||
with:
|
with:
|
||||||
tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean
|
tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean
|
||||||
|
|
||||||
|
|
@ -117,7 +117,7 @@ jobs:
|
||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
|
|
||||||
- name: Install just
|
- name: Install just
|
||||||
uses: taiki-e/install-action@44c6d64aa62cd779e873306675c7a58e86d6d532 # v2.62.49
|
uses: taiki-e/install-action@0be4756f42223b67aa4b7df5effad59010cbf4b9 # v2.62.51
|
||||||
with:
|
with:
|
||||||
tool: just
|
tool: just
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ jobs:
|
||||||
components: llvm-tools
|
components: llvm-tools
|
||||||
|
|
||||||
- name: Install just, cargo-llvm-cov, cargo-nextest
|
- name: Install just, cargo-llvm-cov, cargo-nextest
|
||||||
uses: taiki-e/install-action@44c6d64aa62cd779e873306675c7a58e86d6d532 # v2.62.49
|
uses: taiki-e/install-action@0be4756f42223b67aa4b7df5effad59010cbf4b9 # v2.62.51
|
||||||
with:
|
with:
|
||||||
tool: just,cargo-llvm-cov,cargo-nextest
|
tool: just,cargo-llvm-cov,cargo-nextest
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ jobs:
|
||||||
toolchain: ${{ vars.RUST_VERSION_EXTERNAL_TYPES }}
|
toolchain: ${{ vars.RUST_VERSION_EXTERNAL_TYPES }}
|
||||||
|
|
||||||
- name: Install just
|
- name: Install just
|
||||||
uses: taiki-e/install-action@44c6d64aa62cd779e873306675c7a58e86d6d532 # v2.62.49
|
uses: taiki-e/install-action@0be4756f42223b67aa4b7df5effad59010cbf4b9 # v2.62.51
|
||||||
with:
|
with:
|
||||||
tool: just
|
tool: just
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,14 +110,22 @@ where
|
||||||
|
|
||||||
#[allow(clippy::borrow_interior_mutable_const)]
|
#[allow(clippy::borrow_interior_mutable_const)]
|
||||||
fn call(&self, req: ServiceRequest) -> Self::Future {
|
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
|
// negotiate content-encoding
|
||||||
let accept_encoding = req.get_header::<AcceptEncoding>();
|
let accept_encoding = req.get_header::<AcceptEncoding>();
|
||||||
|
|
||||||
let accept_encoding = match accept_encoding {
|
let accept_encoding = match accept_encoding {
|
||||||
// missing header; fallback to identity
|
// missing header; fallback to identity
|
||||||
None => {
|
None => {
|
||||||
|
req.extensions_mut().insert::<Encoding>(Encoding::identity());
|
||||||
|
|
||||||
return Either::left(CompressResponse {
|
return Either::left(CompressResponse {
|
||||||
encoding: Encoding::identity(),
|
|
||||||
fut: self.service.call(req),
|
fut: self.service.call(req),
|
||||||
_phantom: PhantomData,
|
_phantom: PhantomData,
|
||||||
})
|
})
|
||||||
|
|
@ -143,11 +151,14 @@ where
|
||||||
.map_into_right_body()))
|
.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),
|
fut: self.service.call(req),
|
||||||
encoding,
|
|
||||||
_phantom: PhantomData,
|
_phantom: PhantomData,
|
||||||
}),
|
})
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -159,7 +170,6 @@ pin_project! {
|
||||||
{
|
{
|
||||||
#[pin]
|
#[pin]
|
||||||
fut: S::Future,
|
fut: S::Future,
|
||||||
encoding: Encoding,
|
|
||||||
_phantom: PhantomData<B>,
|
_phantom: PhantomData<B>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -176,8 +186,19 @@ where
|
||||||
|
|
||||||
match ready!(this.fut.poll(cx)) {
|
match ready!(this.fut.poll(cx)) {
|
||||||
Ok(resp) => {
|
Ok(resp) => {
|
||||||
let enc = match this.encoding {
|
let request_encoding = resp.request().extensions().get::<Encoding>().cloned();
|
||||||
Encoding::Known(enc) => *enc,
|
|
||||||
|
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) => {
|
Encoding::Unknown(enc) => {
|
||||||
unimplemented!("encoding '{enc}' should not be here");
|
unimplemented!("encoding '{enc}' should not be here");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue