-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Observing requests/responses and passing them on? #5
Comments
Hey, James! Hmm, doing so is not built-in, that's for sure. So, I don't know of a quick way to do that to suggest you either. You would have to mock or intercept that internal socket object (which you can see in Have you looked into some existing "proxy" modules? Are there any? Perhaps they do that heavy lifting for you. It does seem like a common problem, at least proxying. Though those proxies might not work with SSL. |
Would be nice to be able to do this with |
That's cool. I'll put a link to it in the README. ;-) Mind enlightening me how you use that request observing? |
When I'm writing a scraper or something, it is pretty common to have a request fail because the browser does it one way and Node.js does it another way. This makes it a lot easier to figure out which headers are different. Eventually I'd like to come up with a clever way to use |
Okay, debugging differences between requests sounds reasonable. I wouldn't suggest, however, for you to create tests with entire requests. They're very unmaintainable. You're far better off creating test cases with the minimal reproducible parameters by hand. I briefly mentioned that here, too: #1 (comment). |
Actually something like Betamax mentioned in #1 is what I really want. I'm not sure I understand the problem with that approach - my first thought would be to start with the server response and pare it down, removing unnecessary stuff like date and caching headers. Can you give an example of how this would become hard to maintain? |
Given that to get decent coverage you'd have to ensure every branch, conditional, boundary and statement gets executed, and preferably, do so in separate test cases. Lugging around huge responses for otherwise tiny tests is cumbersome, especially for the code reviewer. There's no reason either to include irrelevant response properties whose handling gets exercised in another test. I'd say white-list approach (select only the properties absolutely necessary) is simpler than trying to pare things down. If the endpoint's API is unclear or unspecified, then that's a wholly different problem and probably better solved by manual exploratory coding. |
Normally if node-mitm observes a request, then it is not passed on to the server (as you would expect).
I'd like to observe the request, send it to the server, and observe the response as it comes back, but I'm having a hard time figuring out what to put in the
'request'
event handler to make this work. Is this possible?The text was updated successfully, but these errors were encountered: