-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
requests should be event emitters #17
Comments
@focusaurus, the It's possible you believe If you have any additional questions or comments feel free to reopen this issue. |
Node's http.IncomingMessage subclasses Stream.readable as seen here. Stream.readable inherits from stream, which is an event emitter as seen here In the repl, you can see that http.IncomingMessage clearly has an "on" function.
Streaming in node is built upon the event emitter pattern, and HTTP messages support streaming. |
@focusaurus, you're absolutely right. My apologies. Let me see if I can work on implementing this. |
We're scheduling this feature for our |
I worked around this issue by mashing an instance of node-memorystream with node-mock-http's mockRequest. The mockRequest is then a stream, complete with event support sufficient to fool body-parser. The end() method is used to flush the stream. Underscore hackery aside, this seems like a reasonable approach to supporting request-as-stream. Would a pull request for adding stream support based on node-memorystream be welcomed?
|
Hey, I came across this also and just added the following in mockRequest.js:
This allows me to fire events on the mockRequest in test cases. Happy to submit a PR. |
Here's a sample commit link with the change. |
Stale issue message |
I need to mock doing
req.on('end', onEnd);
and the mock request class does not have the event emitter methods.The text was updated successfully, but these errors were encountered: