mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-26 06:57:43 +02:00
refactor websocket key hashing (#2035)
This commit is contained in:
@ -15,10 +15,13 @@ use actix::{
|
||||
SpawnHandle,
|
||||
};
|
||||
use actix_codec::{Decoder, Encoder};
|
||||
use actix_http::ws::{hash_key, Codec};
|
||||
pub use actix_http::ws::{
|
||||
CloseCode, CloseReason, Frame, HandshakeError, Message, ProtocolError,
|
||||
};
|
||||
use actix_http::{
|
||||
http::HeaderValue,
|
||||
ws::{hash_key, Codec},
|
||||
};
|
||||
use actix_web::dev::HttpResponseBuilder;
|
||||
use actix_web::error::{Error, PayloadError};
|
||||
use actix_web::http::{header, Method, StatusCode};
|
||||
@ -162,7 +165,11 @@ pub fn handshake_with_protocols(
|
||||
|
||||
let mut response = HttpResponse::build(StatusCode::SWITCHING_PROTOCOLS)
|
||||
.upgrade("websocket")
|
||||
.insert_header((header::SEC_WEBSOCKET_ACCEPT, key))
|
||||
.insert_header((
|
||||
header::SEC_WEBSOCKET_ACCEPT,
|
||||
// key is known to be header value safe ascii
|
||||
HeaderValue::from_bytes(&key).unwrap(),
|
||||
))
|
||||
.take();
|
||||
|
||||
if let Some(protocol) = protocol {
|
||||
|
Reference in New Issue
Block a user