diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index 6d9001f3a..773f1ff39 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -10,6 +10,7 @@ * Impl `MessageBody` for `bytestring::ByteString`. [#2468] * `impl Clone for ws::HandshakeError`. [#2468] * `#[must_use]` for `ws::Codec` to prevent subtle bugs. [#1920] +* `impl Default ` for `ws::Codec`. [#1920] ### Changed * Rename `body::BoxBody::{from_body => new}`. [#2468] @@ -19,7 +20,6 @@ * `From` implementations on error types now return a `Response`. [#2468] * `ResponseBuilder::body(B)` now returns `Response>`. [#2468] * `ResponseBuilder::finish()` now returns `Response>`. [#2468] -* `impl Copy` for `ws::Codec`. [#1920] ### Removed * `ResponseBuilder::streaming`. [#2468] diff --git a/actix-http/src/ws/codec.rs b/actix-http/src/ws/codec.rs index a110982f7..d80613e5f 100644 --- a/actix-http/src/ws/codec.rs +++ b/actix-http/src/ws/codec.rs @@ -90,7 +90,7 @@ impl Codec { /// Set max frame size. /// /// By default max size is set to 64KiB. - #[must_use = "this returns the a new Codec, without modifying the original"] + #[must_use = "This returns the a new Codec, without modifying the original."] pub fn max_size(mut self, size: usize) -> Self { self.max_size = size; self @@ -99,7 +99,7 @@ impl Codec { /// Set decoder to client mode. /// /// By default decoder works in server mode. - #[must_use = "this returns the a new Codec, without modifying the original"] + #[must_use = "This returns the a new Codec, without modifying the original."] pub fn client_mode(mut self) -> Self { self.flags.remove(Flags::SERVER); self diff --git a/actix-web-actors/tests/test_ws.rs b/actix-web-actors/tests/test_ws.rs index 23002efed..a9eb37699 100644 --- a/actix-web-actors/tests/test_ws.rs +++ b/actix-web-actors/tests/test_ws.rs @@ -55,7 +55,7 @@ async fn common_test_code(mut srv: actix_test::TestServer, frame_size: usize) { } #[actix_rt::test] -async fn test_builder() { +async fn simple_builder() { let srv = actix_test::start(|| { App::new().service(web::resource("/").to( |req: HttpRequest, stream: web::Payload| async move { @@ -68,7 +68,7 @@ async fn test_builder() { } #[actix_rt::test] -async fn test_builder_with_frame_size() { +async fn builder_with_frame_size() { let srv = actix_test::start(|| { App::new().service(web::resource("/").to( |req: HttpRequest, stream: web::Payload| async move { @@ -83,7 +83,7 @@ async fn test_builder_with_frame_size() { } #[actix_rt::test] -async fn test_builder_with_frame_size_exceeded() { +async fn builder_with_frame_size_exceeded() { const MAX_FRAME_SIZE: usize = 64; let mut srv = actix_test::start(|| { @@ -112,7 +112,7 @@ async fn test_builder_with_frame_size_exceeded() { } #[actix_rt::test] -async fn test_builder_with_codec() { +async fn builder_with_codec() { let srv = actix_test::start(|| { App::new().service(web::resource("/").to( |req: HttpRequest, stream: web::Payload| async move { @@ -127,7 +127,7 @@ async fn test_builder_with_codec() { } #[actix_rt::test] -async fn test_builder_with_protocols() { +async fn builder_with_protocols() { let srv = actix_test::start(|| { App::new().service(web::resource("/").to( |req: HttpRequest, stream: web::Payload| async move { @@ -142,7 +142,23 @@ async fn test_builder_with_protocols() { } #[actix_rt::test] -async fn test_builder_full() { +async fn builder_with_codec_and_frame_size() { + let srv = actix_test::start(|| { + App::new().service(web::resource("/").to( + |req: HttpRequest, stream: web::Payload| async move { + ws::WsResponseBuilder::new(Ws, &req, stream) + .codec(Codec::new()) + .frame_size(MAX_FRAME_SIZE) + .start() + }, + )) + }); + + common_test_code(srv, DEFAULT_FRAME_SIZE).await; +} + +#[actix_rt::test] +async fn builder_full() { let srv = actix_test::start(|| { App::new().service(web::resource("/").to( |req: HttpRequest, stream: web::Payload| async move { @@ -159,23 +175,7 @@ async fn test_builder_full() { } #[actix_rt::test] -async fn test_builder_with_codec_and_frame_size() { - let srv = actix_test::start(|| { - App::new().service(web::resource("/").to( - |req: HttpRequest, stream: web::Payload| async move { - ws::WsResponseBuilder::new(Ws, &req, stream) - .codec(Codec::new()) - .frame_size(MAX_FRAME_SIZE) - .start() - }, - )) - }); - - common_test_code(srv, DEFAULT_FRAME_SIZE).await; -} - -#[actix_rt::test] -async fn test_simple() { +async fn simple_start() { let srv = actix_test::start(|| { App::new().service(web::resource("/").to( |req: HttpRequest, stream: web::Payload| async move { ws::start(Ws, &req, stream) },