1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-06-02 21:39:26 +00:00
This commit is contained in:
Rob Ede 2021-06-24 15:11:01 +01:00
parent 2d8d2f5ab0
commit 93aa86e30b
No known key found for this signature in database
GPG key ID: 97C636207D3EF933
2 changed files with 20 additions and 16 deletions

View file

@ -480,6 +480,7 @@ impl ClientRequest {
// supported, so we cannot guess Accept-Encoding HTTP header.
if slf.response_decompress {
// Set Accept-Encoding with compression algorithm awc is built with.
#[allow(clippy::vec_init_then_push)]
#[cfg(feature = "__compress")]
let accept_encoding = {
let mut encoding = vec![];
@ -496,7 +497,11 @@ impl ClientRequest {
#[cfg(feature = "compress-zstd")]
encoding.push("zstd");
assert!(!encoding.is_empty(), "encoding cannot be empty unless __compress feature has been explictily enabled.");
assert!(
!encoding.is_empty(),
"encoding can not be empty unless __compress feature has been explicitly enabled"
);
encoding.join(", ")
};

View file

@ -1,12 +1,14 @@
use actix_utils::future::{ok, Ready};
use actix_web::dev::{Service, ServiceRequest, ServiceResponse, Transform};
use actix_web::test::{call_service, init_service, TestRequest};
use actix_web::{HttpResponse, ResponseError};
use futures_util::lock::Mutex;
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;
use std::task::{Context, Poll};
use actix_utils::future::{ok, Ready};
use actix_web::{
dev::{forward_ready, Service, ServiceRequest, ServiceResponse, Transform},
get,
test::{call_service, init_service, TestRequest},
ResponseError,
};
use futures_core::future::LocalBoxFuture;
use futures_util::lock::Mutex;
#[derive(Debug, Clone)]
pub struct MyError;
@ -19,10 +21,9 @@ impl std::fmt::Display for MyError {
}
}
#[actix_web::get("/test")]
#[get("/test")]
async fn test() -> Result<actix_web::HttpResponse, actix_web::error::Error> {
Err(MyError)?;
Ok(HttpResponse::NoContent().finish())
return Err(MyError.into());
}
#[derive(Clone)]
@ -62,11 +63,9 @@ where
{
type Response = ServiceResponse<B>;
type Error = actix_web::Error;
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>>>>;
type Future = LocalBoxFuture<'static, Result<Self::Response, Self::Error>>;
fn poll_ready(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.service.poll_ready(cx)
}
forward_ready!(service);
fn call(&self, req: ServiceRequest) -> Self::Future {
let lock = self.was_error.clone();