1. 22 Jan, 2019 10 commits
    • Kenton Varda's avatar
      1325f3c2
    • Kenton Varda's avatar
      Skip whenWriteDisconnected() tests on Cygwin, where they don't seem to work --… · 9201d8c4
      Kenton Varda authored
      Skip whenWriteDisconnected() tests on Cygwin, where they don't seem to work -- the promise never resolves.
      9201d8c4
    • Kenton Varda's avatar
    • Kenton Varda's avatar
      Fix http-socketpair-test failure in WebSocket piping. · a90c65f4
      Kenton Varda authored
      The test "WebSocket pump disconnect on send" tests what happens if a send() throws DISCONNECTED while pumping. The test hung forever with socketpairs because the message fits entirely in the socket's send buffer, and thus send() actually completes before the disconnect occurs. This differs from userspace pipes, where there is no buffering, and so the send() doesn't complete until all data is received.
      
      This could be fixed by sending a very large message, so that the send() actually blocks on the receiver. But, the problem reveals that WebSocket pumps won't notice when the destination disconnects unless the source sends some message through. Now that we have whenWriteDisconnected(), we can fix this and proactively end the pump, which also fixes the test.
      
      In fact, we can and should propagate such disconnects backwards: if the destination disconnects, we should close the source. We can do this by adding an abort() method to WebSocket, which incidentally allows us to remove the internal AbortableWebSocket interface which was used specifically by WebSocketPipeImpl.
      a90c65f4
    • Kenton Varda's avatar
    • Kenton Varda's avatar
      Proactively cancel HTTP service when client disconnects. · 674fe0c1
      Kenton Varda authored
      This prevents a hanging service from being a permanent memory leak -- as long as the client is still there waiting.
      
      (TCP servers will need additionally to apply connection-level timeouts/keepalives to detect disappearing clients.)
      674fe0c1
    • Kenton Varda's avatar
      Implement whenWriteDisconnected() everywhere. · 0b9f906e
      Kenton Varda authored
      I decided to make the new method pure-virtual as I wanted to make sure that all wrapper streams properly delegate to the inner stream. We wouldn't want e.g. proactive HTTP cancellation to unexpectedly not work when running over TLS.
      0b9f906e
    • Kenton Varda's avatar
      Add AsyncOutputStream::whenWriteDisconnected(). · d32b388c
      Kenton Varda authored
      This will allow the HTTP server to detect when a client has disconnected and cancel processing the response.
      d32b388c
    • Kenton Varda's avatar
      WebSocket pump() should end at Close message. · 3fcd0f46
      Kenton Varda authored
      This reverts the core change from: https://github.com/capnproto/capnproto/commit/6e4c5ce3c9f31a5e79b50cd9eaae6d03106edf98
      
      There are a few reasons to believe that change was wrong:
      - It meant that a pump would always throw and catch a DISCONNECTED exception, which violates the rule that we don't throw exceptions in "normal" operation.
      - It could lead to trouble when combined with the previous commit, which could delay WebSocket disconnect until the service "completes" -- which would lead to a hang.
      
      The commit message where I introduced this said something about bad behavior on OSX. We should address that directly, if it is still a problem.
      3fcd0f46
    • Kenton Varda's avatar
      Fix HttpClient-from-HttpService wrapper prematurely cancelling service promise. · 90d48343
      Kenton Varda authored
      The client app will typically discard the returned response body upon reading EOF. However, the server app may not actually be "done" with the service callback yet at this point. Usually it completes very soon after, but it may need another turn or two of the event loop. If the client discards the response body stream, the server-side promise is discarded, cancelling whatever was left. This is awkward, so we should instead delay the client from seeing EOF until the server has actually finished up.
      90d48343
  2. 12 Dec, 2018 1 commit
  3. 11 Dec, 2018 6 commits
  4. 10 Dec, 2018 2 commits
  5. 07 Dec, 2018 4 commits
  6. 29 Nov, 2018 2 commits
  7. 26 Nov, 2018 4 commits
  8. 22 Nov, 2018 2 commits
  9. 21 Nov, 2018 1 commit
    • Kenton Varda's avatar
      Extend kj::Url with option to not collapse empty path/query components. · a358282e
      Kenton Varda authored
      This is to fix a complaint about Cloudflare Workers removing these components as requests pass through, which apparently breaks someone's funky URLs.
      
      Arguably "." and ".." processing presents a similar problems. But, allowing ".." to pass through is much more likely to lead to security problems. Browsers will generally process "." and ".." before sending a request (whereas they won't collapse double-slashes), so we're following their lead here.
      a358282e
  10. 17 Nov, 2018 1 commit
  11. 07 Nov, 2018 1 commit
  12. 06 Nov, 2018 1 commit
  13. 05 Nov, 2018 1 commit
    • Kenton Varda's avatar
      Allow WebSocket to keep sending after close(). · 308e5cda
      Kenton Varda authored
      In Cloudflare Workers, we've observed applications in the wild that continue to send messages after a Close message. This is incorrect, but it happens, and we end up logging a spurious error as we attempt to proxy the message through.
      
      By removing this restriction, we can now proxy these WebSockets despite the incorrect usage.
      308e5cda
  14. 29 Oct, 2018 2 commits
  15. 26 Oct, 2018 1 commit
  16. 20 Oct, 2018 1 commit