diff --git a/src/client.rs b/src/client.rs index d7b3f1f..63e4d8f 100644 --- a/src/client.rs +++ b/src/client.rs @@ -73,7 +73,7 @@ fn wrap_stream(stream: TcpStream, _domain: &str, mode: Mode) -> Result(addrs: A, url: &Url, mode: Mode) -> Result where A: Iterator { - let domain = url.host_str().ok_or(Error::Url("No host name in the URL".into()))?; + let domain = url.host_str().ok_or_else(|| Error::Url("No host name in the URL".into()))?; for addr in addrs { debug!("Trying to contact {} at {}...", url, addr); if let Ok(raw_stream) = TcpStream::connect(addr) { diff --git a/src/handshake/server.rs b/src/handshake/server.rs index d389fd3..fbd08b6 100644 --- a/src/handshake/server.rs +++ b/src/handshake/server.rs @@ -18,7 +18,7 @@ impl Request { /// Reply to the response. pub fn reply(&self) -> Result> { let key = self.headers.find_first("Sec-WebSocket-Key") - .ok_or(Error::Protocol("Missing Sec-WebSocket-Key".into()))?; + .ok_or_else(|| Error::Protocol("Missing Sec-WebSocket-Key".into()))?; let reply = format!("\ HTTP/1.1 101 Switching Protocols\r\n\ Connection: Upgrade\r\n\