summaryrefslogtreecommitdiff
path: root/ext/flash/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ext/flash/lib.rs')
-rw-r--r--ext/flash/lib.rs56
1 files changed, 41 insertions, 15 deletions
diff --git a/ext/flash/lib.rs b/ext/flash/lib.rs
index 65d52d083..0714e379d 100644
--- a/ext/flash/lib.rs
+++ b/ext/flash/lib.rs
@@ -987,22 +987,48 @@ fn run_server(
// sockets.remove(&token);
continue 'events;
}
- Ok(read) => match req.parse(&buffer[..offset + read]) {
- Ok(httparse::Status::Complete(n)) => {
- body_offset = n;
- body_len = offset + read;
- socket.parse_done = ParseStatus::None;
- break;
- }
- Ok(httparse::Status::Partial) => {
- socket.parse_done = ParseStatus::Ongoing(offset + read);
- continue;
- }
- Err(_) => {
- let _ = socket.write(b"HTTP/1.1 400 Bad Request\r\n\r\n");
- continue 'events;
+ Ok(read) => {
+ match req.parse(&buffer[..offset + read]) {
+ Ok(httparse::Status::Complete(n)) => {
+ body_offset = n;
+ body_len = offset + read;
+ socket.parse_done = ParseStatus::None;
+ // On Windows, We must keep calling socket.read() until it fails with WouldBlock.
+ //
+ // Mio tries to emulate edge triggered events on Windows.
+ // AFAICT it only rearms the event on WouldBlock, but it doesn't when a partial read happens.
+ // https://github.com/denoland/deno/issues/15549
+ #[cfg(target_os = "windows")]
+ match &mut socket.inner {
+ InnerStream::Tcp(ref mut socket) => {
+ poll
+ .registry()
+ .reregister(socket, token, Interest::READABLE)
+ .unwrap();
+ }
+ InnerStream::Tls(ref mut socket) => {
+ poll
+ .registry()
+ .reregister(
+ &mut socket.sock,
+ token,
+ Interest::READABLE,
+ )
+ .unwrap();
+ }
+ };
+ break;
+ }
+ Ok(httparse::Status::Partial) => {
+ socket.parse_done = ParseStatus::Ongoing(offset + read);
+ continue;
+ }
+ Err(_) => {
+ let _ = socket.write(b"HTTP/1.1 400 Bad Request\r\n\r\n");
+ continue 'events;
+ }
}
- },
+ }
Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock => {
break 'events
}