Skip to content

Conversation

@kettanaito
Copy link
Member

@kettanaito kettanaito commented Sep 27, 2024

Changes

  • The 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:
req.on('socket', (socket) => {
  socket.on('connect', () => req.end())
})

Here, the request header won't be sent until the socket connection is established. Previously, the interceptor would hang on this forever since writing the request header was mandatory as it triggers the request parser).

  • Refactors MockHttpSocket class a bit so both conventional write+end requests as well as write + end (deferred) requests trigger the same _onRequestStart processing pipeline.

@kettanaito
Copy link
Member Author

Issue

_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants