moll / node-mitm

Intercept and mock outgoing Node.js network TCP connections and HTTP requests for testing. Intercepts and gives you a Net.Socket, Http.IncomingMessage and Http.ServerResponse to test and respond with. Super useful when testing code that hits remote servers.
Other
637 stars 48 forks source link

Expose connect options and the client socket via a _mitm property #33

Open papandreou opened 7 years ago

papandreou commented 7 years ago

Fixes #14.

I ran into a scenario where it was impossible to pair up client sockets, connect options, and HTTP requests using the current API.

This (or something similar) makes it possible to avoid the guesswork and actually simplify my code a bit: https://github.com/unexpectedjs/unexpected-mitm/pull/19/files

papandreou commented 7 years ago

@moll Any feedback on this, or the general idea of providing it?

dempfi commented 7 years ago

This PR also gives a nice way to bypass requests. Like described in https://github.com/moll/node-mitm/issues/16.

jakzo commented 5 years ago

@moll Is there any update on this? My specific problem is that I use .on('request') but I have no way of knowing the full URL since the protocol could be http or https. This PR would solve this issue.

papandreou commented 4 years ago

Ping @moll?

moll commented 2 years ago

I think this still needs addressing. I'll reopen to come around to it eventually. And oh, Feb 17, 2020— that was almost before the apocalypse. Good times!

forty commented 8 months ago

@moll Hi there! This looks super useful, do you think this MR could be moved forward? TIA!