From c461f1d827edd45b3f1b7b2a77ad885c765feff8 Mon Sep 17 00:00:00 2001 From: danielvschoor <43602193+danielvschoor@users.noreply.github.com> Date: Tue, 15 Nov 2022 11:02:12 +0200 Subject: [PATCH] Add accept_unmasked_frames setting in WebSocketUpgrade (#1529) * Add accept_unmasked_frames setting in WebSocketUpgrade * Update CHANGELOG.md * Apply suggestions from code review Co-authored-by: David Pedersen --- axum/CHANGELOG.md | 2 +- axum/src/extract/ws.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/axum/CHANGELOG.md b/axum/CHANGELOG.md index 17646e26..4d0ae283 100644 --- a/axum/CHANGELOG.md +++ b/axum/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 # Unreleased -- None. +- **added:** Add `accept_unmasked_frames` setting in WebSocketUpgrade ([#1529]) # 0.6.0-rc.4 (9. November, 2022) diff --git a/axum/src/extract/ws.rs b/axum/src/extract/ws.rs index dbc38905..63e938c6 100644 --- a/axum/src/extract/ws.rs +++ b/axum/src/extract/ws.rs @@ -164,6 +164,12 @@ impl WebSocketUpgrade { self } + /// Allow server to accept unmasked frames (defaults to false) + pub fn accept_unmasked_frames(mut self, accept: bool) -> Self { + self.config.accept_unmasked_frames = accept; + self + } + /// Set the known protocols. /// /// If the protocol name specified by `Sec-WebSocket-Protocol` header