Skip to content

Commit

Permalink
fix(headers): make Protocol search websocket unicase
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cyderize committed Jan 24, 2015
1 parent fc67a12 commit 65c7018
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/header/common/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use header::{Header, HeaderFormat};
use std::fmt;
use std::str::FromStr;
use header::parsing::{from_comma_delimited, fmt_comma_delimited};
use unicase::UniCase;

use self::Protocol::{WebSocket, ProtocolExt};

Expand All @@ -22,9 +23,11 @@ pub enum Protocol {

impl FromStr for Protocol {
fn from_str(s: &str) -> Option<Protocol> {
match s {
"websocket" => Some(WebSocket),
s => Some(ProtocolExt(s.to_string()))
if UniCase(s) == UniCase("websocket") {
Some(WebSocket)
}
else {
Some(ProtocolExt(s.to_string()))
}
}
}
Expand Down

0 comments on commit 65c7018

Please sign in to comment.