I’m not sure if this is Async specific, but I’m trying to re-use HTTP connections and I can’t figure out how to determine if the connection is alive without trying to send something.
The way Cohttp does this is by calling Reader.read
and checking for EOF, but I don’t want to actually want to block on reading (the server has finished sending the previous response at this point and is waiting for a new request). Reader.peek ~len:0
doesn’t seem to do anything, and Reader.peek ~len:1
would block.
My current strategy is to make a request and then retry if we see Cohttp’s remote connection closed exception but I’d like to do something cleaner if it’s possible.
Is it possible?