Skip to content

Commit

Permalink
allow WebSocket casing for upgrade header (#709)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlinton authored Jan 6, 2024
1 parent 0bf7f16 commit 4367c63
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion poem/src/web/websocket/extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ pub struct WebSocket {

impl WebSocket {
async fn internal_from_request(req: &Request) -> Result<Self, WebSocketError> {
let is_valid_upgrade_header = req.headers().get(header::UPGRADE)
== Some(&HeaderValue::from_static("websocket"))
|| req.headers().get(header::UPGRADE) == Some(&HeaderValue::from_static("WebSocket"));

if req.method() != Method::GET
|| req.headers().get(header::UPGRADE) != Some(&HeaderValue::from_static("websocket"))
|| !is_valid_upgrade_header
|| req.headers().get(header::SEC_WEBSOCKET_VERSION)
!= Some(&HeaderValue::from_static("13"))
{
Expand Down

0 comments on commit 4367c63

Please sign in to comment.