I modified a mini server with "use std::net::TcpListener; use std::net::TcpStream;" from the Rust Book example (https://doc.rust-lang.org/book/ch20-03-graceful-shutdown-and-cleanup.html).
This code works from Firefox browser common "form" sending a "input type='file'" with obviously "'enctype='multipart/form-data'":
let mut datax = Vec::new();
let mut el_buffer = [0; 1024];
let mut limita = 0;
loop {
let n = stream.read(&mut el_buffer).unwrap();
if n<1024 {
datax.extend_from_slice(&el_buffer[..n]);
break;
} else {
datax.extend_from_slice(&el_buffer[..n]);
}
if limita >10000 {
break;
}
limita += 1;
}
I tried: read_to_end(); read_exact(); BufReader::new(&stream); let mut el_buffer = [0; 1024]; // 1, 512, 4092, 10240, 102400, 2000 etc.
I tried "n==0... break"
I tried read without loop...
The result is the same:
From Firefox read all the file and works.
From Edge, Chrome, IE, cuts the POST received and the browser loses the server connection.