fix(headers): make Protocol search websocket unicase
RFC6455 requires the Upgrade Protocol to search case-insensitively for "websocket" Other protocol values may be case-sensitive, however, so ProtocolExt is still case-sensitive
This commit is contained in:
		| @@ -2,6 +2,7 @@ use header::{Header, HeaderFormat}; | |||||||
| use std::fmt; | use std::fmt; | ||||||
| use std::str::FromStr; | use std::str::FromStr; | ||||||
| use header::parsing::{from_comma_delimited, fmt_comma_delimited}; | use header::parsing::{from_comma_delimited, fmt_comma_delimited}; | ||||||
|  | use unicase::UniCase; | ||||||
|  |  | ||||||
| use self::Protocol::{WebSocket, ProtocolExt}; | use self::Protocol::{WebSocket, ProtocolExt}; | ||||||
|  |  | ||||||
| @@ -22,9 +23,11 @@ pub enum Protocol { | |||||||
|  |  | ||||||
| impl FromStr for Protocol { | impl FromStr for Protocol { | ||||||
|     fn from_str(s: &str) -> Option<Protocol> { |     fn from_str(s: &str) -> Option<Protocol> { | ||||||
|         match s { |         if UniCase(s) == UniCase("websocket") { | ||||||
|             "websocket" => Some(WebSocket), |             Some(WebSocket) | ||||||
|             s => Some(ProtocolExt(s.to_string())) |         } | ||||||
|  |         else { | ||||||
|  |             Some(ProtocolExt(s.to_string())) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user