diff --git a/CHANGELOG.md b/CHANGELOG.md index e314e93a..c7f7703b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -144,6 +144,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 // ... } ``` +- Misc: + - `InvalidWebsocketVersionHeader` has been renamed to `InvalidWebSocketVersionHeader` ([#416]) + - `WebsocketKeyHeaderMissing` has been renamed to `WebSocketKeyHeaderMissing` ([#416]) [#339]: https://github.com/tokio-rs/axum/pull/339 [#286]: https://github.com/tokio-rs/axum/pull/286 @@ -156,6 +159,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#405]: https://github.com/tokio-rs/axum/pull/405 [#408]: https://github.com/tokio-rs/axum/pull/408 [#412]: https://github.com/tokio-rs/axum/pull/412 +[#416]: https://github.com/tokio-rs/axum/pull/416 # 0.2.8 (07. October, 2021) diff --git a/examples/chat/chat.html b/examples/chat/chat.html index d1c665e0..c062f380 100644 --- a/examples/chat/chat.html +++ b/examples/chat/chat.html @@ -1,52 +1,52 @@ - - - Websocket Chat - - -

Websocket Chat Example

+ + + WebSocket Chat + + +

WebSocket Chat Example

- - - - + + + + - - + input.onkeydown = function(e) { + if (e.key == "Enter") { + websocket.send(input.value); + input.value = ""; + } + } + }); + + diff --git a/src/extract/ws.rs b/src/extract/ws.rs index 4b76857c..c5a06989 100644 --- a/src/extract/ws.rs +++ b/src/extract/ws.rs @@ -209,7 +209,7 @@ where } if !header_eq(req, header::SEC_WEBSOCKET_VERSION, "13")? { - return Err(InvalidWebsocketVersionHeader.into()); + return Err(InvalidWebSocketVersionHeader.into()); } let sec_websocket_key = if let Some(key) = req @@ -219,7 +219,7 @@ where { key } else { - return Err(WebsocketKeyHeaderMissing.into()); + return Err(WebSocketKeyHeaderMissing.into()); }; let on_upgrade = req @@ -309,7 +309,7 @@ where } else { return ( StatusCode::BAD_REQUEST, - "`Sec-Websocket-Protocol` header is invalid", + "`Sec-WebSocket-Protocol` header is invalid", ) .into_response(); } @@ -578,16 +578,16 @@ pub mod rejection { define_rejection! { #[status = BAD_REQUEST] - #[body = "`Sec-Websocket-Version` header did not include '13'"] + #[body = "`Sec-WebSocket-Version` header did not include '13'"] /// Rejection type for [`WebSocketUpgrade`](super::WebSocketUpgrade). - pub struct InvalidWebsocketVersionHeader; + pub struct InvalidWebSocketVersionHeader; } define_rejection! { #[status = BAD_REQUEST] - #[body = "`Sec-Websocket-Key` header missing"] + #[body = "`Sec-WebSocket-Key` header missing"] /// Rejection type for [`WebSocketUpgrade`](super::WebSocketUpgrade). - pub struct WebsocketKeyHeaderMissing; + pub struct WebSocketKeyHeaderMissing; } composite_rejection! { @@ -599,8 +599,8 @@ pub mod rejection { MethodNotGet, InvalidConnectionHeader, InvalidUpgradeHeader, - InvalidWebsocketVersionHeader, - WebsocketKeyHeaderMissing, + InvalidWebSocketVersionHeader, + WebSocketKeyHeaderMissing, HeadersAlreadyExtracted, ExtensionsAlreadyExtracted, }