Make sure all data is written to socket
Using `write` means that it's possible that not all data gets written out. Rather than check the return value and write in a loop, just use `write_all`.
This commit is contained in:
+2
-2
@@ -33,7 +33,7 @@ fn read_body<T: Read + Write>(length: u32, socket: &mut ProxySocket<T>) {
|
|||||||
|
|
||||||
if let Ok(_) = handle.read_exact(&mut buffer) {
|
if let Ok(_) = handle.read_exact(&mut buffer) {
|
||||||
if valid_length(length) {
|
if valid_length(length) {
|
||||||
socket.write(&buffer).unwrap();
|
socket.write_all(&buffer).unwrap();
|
||||||
socket.flush().unwrap();
|
socket.flush().unwrap();
|
||||||
read_response(socket);
|
read_response(socket);
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ fn write_response(buf: &[u8]) {
|
|||||||
let mut out = stdout.lock();
|
let mut out = stdout.lock();
|
||||||
|
|
||||||
out.write_u32::<NativeEndian>(buf.len() as u32).unwrap();
|
out.write_u32::<NativeEndian>(buf.len() as u32).unwrap();
|
||||||
out.write(buf).unwrap();
|
out.write_all(buf).unwrap();
|
||||||
out.flush().unwrap();
|
out.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user