Open kettanaito opened 1 month ago
_read
is non-deterministic and is called multiple times during the socket life cycle. We cannot rely on it to check if someone has written to the socket yet. Also, writes can happen after _read
, which defeats its entire purpose.
I'm trying to see what we can do to make this process more streamlined... Ideally, we can trigger onRequest
on MockHttpSocket.connect
. If the request listener consumes the request body, we are flushing the request header buffer anyway right now to make that read possible.
Changes
MockHttpSocket
class now has a special scenario for buffered requests. A buffered request is one whose stream is pending while the connection is being established. Example:MockHttpSocket
class a bit so both conventional write+end requests as well as write + end (deferred) requests trigger the same_onRequestStart
processing pipeline.