File tree 1 file changed +7
-12
lines changed
1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -23,22 +23,17 @@ pub enum ValidationError {
23
23
pub ( crate ) fn validate_response_headers (
24
24
response : Response < Option < Vec < u8 > > > ,
25
25
) -> Result < ( ) , ValidationError > {
26
- let val = response
26
+ let subprotocol = response
27
27
. headers ( )
28
28
. get ( "Sec-WebSocket-Protocol" )
29
- . ok_or ( ValidationError :: SubprotocolHeaderMissing ) ?;
29
+ . ok_or ( ValidationError :: SubprotocolHeaderMissing ) ?
30
+ . to_str ( ) ?;
30
31
31
- let subprotocols = val. to_str ( ) ?;
32
-
33
- // In Sec-WebSocket-Protocol header
34
- // multiple subprotocols can be listed in a comma-delimited format
35
- // e.g. Sec-WebSocket-Protocol: mqtt, chat
36
- if !subprotocols
37
- . split ( ',' )
38
- . any ( |protocol| protocol. trim ( ) == "mqtt" )
39
- {
32
+ // Server must respond with Sec-WebSocket-Protocol header value of "mqtt"
33
+ // https://http.dev/ws#sec-websocket-protocol
34
+ if subprotocol. trim ( ) != "mqtt" {
40
35
return Err ( ValidationError :: SubprotocolMqttMissing (
41
- subprotocols . to_owned ( ) ,
36
+ subprotocol . to_owned ( ) ,
42
37
) ) ;
43
38
}
44
39
You can’t perform that action at this time.
0 commit comments