diff --git a/src/util/header.rs b/src/util/header.rs index aaf8059978..2ce2af9d93 100644 --- a/src/util/header.rs +++ b/src/util/header.rs @@ -34,7 +34,7 @@ impl HeaderCollection { match self.map.insert(lowercase.to_string(), value.to_string()) { Some(old_value) => { //Append if there's already a value - self.map.insert(lowercase.to_string(), old_value + ", ".to_string() + value.to_string()); + self.map.insert(lowercase.to_string(), old_value.to_string() + ", " + value.to_string().as_slice()); } None => { } } diff --git a/src/ws/handshake/request.rs b/src/ws/handshake/request.rs index d353ab2674..72e71ec968 100644 --- a/src/ws/handshake/request.rs +++ b/src/ws/handshake/request.rs @@ -51,13 +51,13 @@ impl WebSocketRequest { _ => { return Err(ParseError::InvalidScheme); } } - let host = match ws_uri.serialize_host() { - Some(host) => { host } + let host : String = match ws_uri.serialize_host() { + Some(host) => { host.to_string() } None => { return Err(ParseError::InvalidCharacter); } } + match ws_uri.port_or_default() { - Some(port) => { ":".to_string() + port.to_string() } + Some(port) => { ":".to_string() + port.to_string().as_slice() } None => { return Err(ParseError::InvalidCharacter); } - }; + }.as_slice(); let resource_name = match ws_uri.serialize_path() { Some(resource_name) => { @@ -223,7 +223,7 @@ pub trait WriteWebSocketRequest { impl WriteWebSocketRequest for W { fn write_websocket_request(&mut self, request: &WebSocketRequest) -> IoResult<()> { - let request_line = "GET ".to_string() + request.resource_name + " HTTP/".to_string() + request.http_version.to_string(); + let request_line = "GET ".to_string() + request.resource_name.as_slice() + " HTTP/" + request.http_version.to_string().as_slice(); try!(self.write_str(request_line.as_slice())); try!(self.write_str("\r\n")); diff --git a/src/ws/handshake/response.rs b/src/ws/handshake/response.rs index b2a1f5799a..484ba76d38 100644 --- a/src/ws/handshake/response.rs +++ b/src/ws/handshake/response.rs @@ -139,7 +139,7 @@ impl WebSocketResponse { /// Generates the handshake Sec-WebSocket-Accept value from /// the given Sec-WebSocket-Key. pub fn gen_accept(key: A) -> String { - let concat_key = key.to_string() + MAGIC_GUID.to_string(); + let concat_key = key.to_string() + MAGIC_GUID; let mut sha1 = Sha1::new(); sha1.update(concat_key.into_bytes().as_slice()); sha1.digest().as_slice().to_base64(STANDARD) @@ -218,7 +218,9 @@ pub trait WriteWebSocketResponse { impl WriteWebSocketResponse for W { fn write_websocket_response(&mut self, response: &WebSocketResponse) -> IoResult<()> { - let status_line = "HTTP/".to_string() + response.http_version.to_string() + " ".to_string() + response.status_code.to_string() + " ".to_string() + response.reason_phrase; + let mut status_line = "HTTP/".to_string() + response.http_version.to_string().as_slice(); + status_line = status_line + " " + response.status_code.to_string().as_slice(); + status_line = status_line + " " + response.reason_phrase.to_string().as_slice(); try!(self.write_str(status_line.as_slice())); try!(self.write_str("\r\n"));