Repository: websockets-rs/rust-websocket (language: rust)

Issue:
Autobahn broken for Server
See https://cyderize.github.io/rust-websocket/autobahn/ autobahn test regression for the server example.


Discussion / hints:

Fix patch:
diff --git a/examples/autobahn-server.rs b/examples/autobahn-server.rs
index f9a8d959e9..3d27f1e647 100644
--- a/examples/autobahn-server.rs
+++ b/examples/autobahn-server.rs
@@ -8,7 +8,8 @@ use websocket::message::Type;
 fn main() {
 	let server = Server::bind("127.0.0.1:9002").unwrap();
 
-	for connection in server {
+	for connection in server.filter_map(Result::ok) {
+
 		thread::spawn(move || {
 			let client = connection.accept().unwrap();
 
diff --git a/examples/hyper.rs b/examples/hyper.rs
index f5b8b21248..de1880a024 100644
--- a/examples/hyper.rs
+++ b/examples/hyper.rs
@@ -30,7 +30,7 @@ fn main() {
 	// Start listening for WebSocket connections
 	let ws_server = Server::bind("127.0.0.1:2794").unwrap();
 
-	for connection in ws_server {
+	for connection in ws_server.filter_map(Result::ok) {
 		// Spawn a new thread for each connection.
 		thread::spawn(move || {
 			if !connection.protocols().contains(&"rust-websocket".to_string()) {
diff --git a/examples/server.rs b/examples/server.rs
index dd11f5a098..3dd9799979 100644
--- a/examples/server.rs
+++ b/examples/server.rs
@@ -7,7 +7,7 @@ use websocket::message::Type;
 fn main() {
 	let server = Server::bind("127.0.0.1:2794").unwrap();
 
-	for request in server {
+	for request in server.filter_map(Result::ok) {
 		// Spawn a new thread for each connection.
 		thread::spawn(move || {
 			if !request.protocols().contains(&"rust-websocket".to_string()) {
diff --git a/src/server/mod.rs b/src/server/mod.rs
index 44a5497101..2994c56979 100644
--- a/src/server/mod.rs
+++ b/src/server/mod.rs
@@ -65,7 +65,7 @@ impl OptionalSslAcceptor for SslAcceptor {}
 ///
 ///let server = Server::bind("127.0.0.1:1234").unwrap();
 ///
-///for connection in server {
+///for connection in server.filter_map(Result::ok) {
 ///    // Spawn a new thread for each connection.
 ///    thread::spawn(move || {
 ///		   let mut client = connection.accept().unwrap();
@@ -109,7 +109,7 @@ impl OptionalSslAcceptor for SslAcceptor {}
 ///
 ///let server = Server::bind_secure("127.0.0.1:1234", acceptor).unwrap();
 ///
-///for connection in server {
+///for connection in server.filter_map(Result::ok) {
 ///    // Spawn a new thread for each connection.
 ///    thread::spawn(move || {
 ///		   let mut client = connection.accept().unwrap();
@@ -220,10 +220,10 @@ impl Server<SslAcceptor> {
 
 #[cfg(feature="ssl")]
 impl Iterator for Server<SslAcceptor> {
-	type Item = WsUpgrade<SslStream<TcpStream>>;
+	type Item = AcceptResult<SslStream<TcpStream>>;
 
 	fn next(&mut self) -> Option<<Self as Iterator>::Item> {
-		self.accept().ok()
+		Some(self.accept())
 	}
 }
 
@@ -265,9 +265,9 @@ impl Server<NoSslAcceptor> {
 }
 
 impl Iterator for Server<NoSslAcceptor> {
-	type Item = WsUpgrade<TcpStream>;
+	type Item = AcceptResult<TcpStream>;
 
 	fn next(&mut self) -> Option<<Self as Iterator>::Item> {
-		self.accept().ok()
+		Some(self.accept())
 	}
 }
diff --git a/src/server/upgrade/mod.rs b/src/server/upgrade/mod.rs
index 51fa4332fe..51617ae525 100644
--- a/src/server/upgrade/mod.rs
+++ b/src/server/upgrade/mod.rs
@@ -31,6 +31,7 @@ pub mod from_hyper;
 ///
 /// This struct represents bytes that have already been read in from the stream.
 /// A slice of valid data in this buffer can be obtained by: `&buf[pos..cap]`.
+#[derive(Debug)]
 pub struct Buffer {
 	/// the contents of the buffered stream data
 	pub buf: Vec<u8>,
@@ -415,7 +416,7 @@ fn validate(
 	fn check_connection_header(headers: &Vec<ConnectionOption>) -> bool {
 		for header in headers {
 			if let &ConnectionOption::ConnectionHeader(ref h) = header {
-				if h as &str == "upgrade" {
+				if UniCase(h as &str) == UniCase("upgrade") {
 					return true;
 				}
 			}


Test patch: