fix: tests::support::server
If the length of expected header is accidentally larger than the length of the actual header, `socket.read()` will keep pulling bytes from the socket which could no longer produce any, hence the later calls of `socket.read` will return a `WouldBlock` Error.
This commit is contained in:
		| @@ -51,7 +51,10 @@ pub fn spawn(txns: Vec<Txn>) -> Server { | |||||||
|  |  | ||||||
|             let mut n = 0; |             let mut n = 0; | ||||||
|             while n < expected.len() { |             while n < expected.len() { | ||||||
|                 n += socket.read(&mut buf).unwrap(); |                 match socket.read(&mut buf[n..]) { | ||||||
|  |                     Ok(0) | Err(_) => break, | ||||||
|  |                     Ok(nread) => n += nread, | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             match (::std::str::from_utf8(&expected), ::std::str::from_utf8(&buf[..n])) { |             match (::std::str::from_utf8(&expected), ::std::str::from_utf8(&buf[..n])) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user