diff --git a/actix-http/src/ws/mod.rs b/actix-http/src/ws/mod.rs index a6ae2e5cd..7df924cf5 100644 --- a/actix-http/src/ws/mod.rs +++ b/actix-http/src/ws/mod.rs @@ -141,7 +141,7 @@ impl From<&HandshakeError> for Response { impl From for Response { fn from(err: HandshakeError) -> Self { - err.into() + (&err).into() } } diff --git a/actix-http/tests/test_rustls.rs b/actix-http/tests/test_rustls.rs index 61255fbcb..b2c66e871 100644 --- a/actix-http/tests/test_rustls.rs +++ b/actix-http/tests/test_rustls.rs @@ -417,7 +417,10 @@ async fn test_h2_response_http_error_handling() { // read response let bytes = srv.load_body(response).await.unwrap(); - assert_eq!(bytes, Bytes::from_static(b"failed to parse header value")); + assert_eq!( + bytes, + Bytes::from_static(b"error processing HTTP: failed to parse header value") + ); } #[derive(Debug, Display, Error)] @@ -426,7 +429,7 @@ struct BadRequest; impl From for Response { fn from(_: BadRequest) -> Self { - Response::bad_request() + Response::bad_request().set_body(AnyBody::from("error")) } } diff --git a/actix-http/tests/test_server.rs b/actix-http/tests/test_server.rs index be79bf738..1eb0a838d 100644 --- a/actix-http/tests/test_server.rs +++ b/actix-http/tests/test_server.rs @@ -91,7 +91,7 @@ async fn test_expect_continue() { let _ = stream.write_all(b"GET /test HTTP/1.1\r\nexpect: 100-continue\r\n\r\n"); let mut data = String::new(); let _ = stream.read_to_string(&mut data); - assert!(data.starts_with("HTTP/1.1 412 Expectation Failed\r\ncontent-length")); + assert!(data.starts_with("HTTP/1.1 417 Expectation Failed\r\ncontent-length")); let mut stream = net::TcpStream::connect(srv.addr()).unwrap(); let _ = stream.write_all(b"GET /test?yes= HTTP/1.1\r\nexpect: 100-continue\r\n\r\n"); @@ -122,7 +122,7 @@ async fn test_expect_continue_h1() { let _ = stream.write_all(b"GET /test HTTP/1.1\r\nexpect: 100-continue\r\n\r\n"); let mut data = String::new(); let _ = stream.read_to_string(&mut data); - assert!(data.starts_with("HTTP/1.1 412 Precondition Failed\r\ncontent-length")); + assert!(data.starts_with("HTTP/1.1 417 Expectation Failed\r\ncontent-length")); let mut stream = net::TcpStream::connect(srv.addr()).unwrap(); let _ = stream.write_all(b"GET /test?yes= HTTP/1.1\r\nexpect: 100-continue\r\n\r\n"); @@ -657,7 +657,7 @@ async fn test_h1_response_http_error_handling() { // read response let bytes = srv.load_body(response).await.unwrap(); - assert_eq!(bytes, Bytes::from_static(b"failed to parse header value")); + assert_eq!(bytes, Bytes::from_static(b"error processing HTTP: failed to parse header value")); } #[derive(Debug, Display, Error)] @@ -666,7 +666,7 @@ struct BadRequest; impl From for Response { fn from(_: BadRequest) -> Self { - Response::bad_request() + Response::bad_request().set_body(AnyBody::from("error")) } } diff --git a/src/error/mod.rs b/src/error/mod.rs index bc7081ff3..cc6d09b48 100644 --- a/src/error/mod.rs +++ b/src/error/mod.rs @@ -19,7 +19,7 @@ pub use self::response_error::{Error, ResponseError}; /// A convenience [`Result`](std::result::Result) for Actix Web operations. /// /// This type alias is generally used to avoid writing out `actix_http::Error` directly. -pub type Result = std::result::Result; +pub type Result = std::result::Result; /// Errors which can occur when attempting to generate resource uri. #[derive(Debug, PartialEq, Display, Error, From)] diff --git a/src/request.rs b/src/request.rs index e3da991de..752a88d61 100644 --- a/src/request.rs +++ b/src/request.rs @@ -7,7 +7,7 @@ use std::{ use actix_http::{ http::{HeaderMap, Method, Uri, Version}, - Error, Extensions, HttpMessage, Message, Payload, RequestHead, + Extensions, HttpMessage, Message, Payload, RequestHead, }; use actix_router::{Path, Url}; use actix_utils::future::{ok, Ready}; @@ -17,7 +17,7 @@ use smallvec::SmallVec; use crate::{ app_service::AppInitServiceState, config::AppConfig, error::UrlGenerationError, - extract::FromRequest, info::ConnectionInfo, rmap::ResourceMap, + info::ConnectionInfo, rmap::ResourceMap, Error, FromRequest, }; #[cfg(feature = "cookies")] diff --git a/src/route.rs b/src/route.rs index b308a93aa..44f7e30b8 100644 --- a/src/route.rs +++ b/src/route.rs @@ -188,8 +188,7 @@ impl Route { #[cfg(test)] mod tests { - use std::convert::Infallible; - use std::time::Duration; + use std::{convert::Infallible, time::Duration}; use actix_rt::time::sleep; use bytes::Bytes;