Fix ws tests.

This commit is contained in:
Tomasz Drwięga 2017-10-23 23:52:50 +02:00
parent 5f5476ceb8
commit dd21e61371
No known key found for this signature in database
GPG Key ID: D066F497E62CAF66

View File

@ -16,7 +16,7 @@
use std::thread; use std::thread;
use std::time::Duration; use std::time::Duration;
use std::io::{Read, Write}; use std::io::{self, Read, Write};
use std::str::{self, Lines}; use std::str::{self, Lines};
use std::net::{TcpStream, SocketAddr}; use std::net::{TcpStream, SocketAddr};
@ -87,6 +87,7 @@ pub fn request(address: &SocketAddr, request: &str) -> Response {
loop { loop {
let mut chunk = [0; 32 *1024]; let mut chunk = [0; 32 *1024];
match req.read(&mut chunk) { match req.read(&mut chunk) {
Err(ref err) if err.kind() == io::ErrorKind::WouldBlock => break,
Err(err) => panic!("Unable to read response: {:?}", err), Err(err) => panic!("Unable to read response: {:?}", err),
Ok(0) => break, Ok(0) => break,
Ok(read) => response.extend_from_slice(&chunk[..read]), Ok(read) => response.extend_from_slice(&chunk[..read]),