Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/connection.toit
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class Connection:
headers-written := false
no-delay-restored := false
try:
socket_.no-delay = false
set-no-delay_ false
writer.write status
headers.write-to writer
if is-client-request and host_:
Expand All @@ -162,7 +162,7 @@ class Connection:
// finally ensures that we still close while its exception propagates.
try:
if headers-written:
socket_.no-delay = true
set-no-delay_ true
no-delay-restored = true
finally:
// A partial header or a failed TCP_NODELAY restoration makes the
Expand All @@ -173,6 +173,13 @@ class Connection:

return body-writer

set-no-delay_ value/bool -> none:
exception := catch --unwind=(: it != "Invalid argument"):
socket_.no-delay = value
// macOS rejects socket options with EINVAL once the peer has reset the
// connection. Report that as a close, so that clients can retry.
if exception: throw "Connection closed"

// Gets the next request from the client. If the client closes the
// connection, returns null.
read-request -> RequestIncoming?:
Expand Down
Loading