Add bypass to node and xhr
This is an attempt at a bypass method which follows on https://github.com/algolia/faux-jax/issues/12
It adds it to node and xhr ( i couldn't manually test IE, so I left XDomainRequest).
Working with the XHR native, was a real gnarly one. I had initially hoped to put in the prototype chain, but I couldn't inherit from it. I tried running the xhr methods on a non-xhr instance and failed that too. I think an actual DOM element is made for XHR, but that's just a thought.
Nodejs was simple, but we don't get the whole request. Just the url, which mitm wants to create a socket on. This is the one I actually need. I was hoping for a uniform PR, to include to all other interface.
I'll check back here to cleanup the PR as needed, there might be some travis errors...
I'll take a look at the fails, soon as I'm able.
PS: Forget to mention how this would work...
- Introduced a new event
pre-request, which will have a single arg - The arg will be the request, or a bare bones url ( from nodejs )
- The arg will also have a
.bypassmethod, which when called will set a flag on the request instance - Then
req.send()is called, presence ofreq._bypasswill...- ...use the real methods to create an ajax/http request
- ... fire the request, and copy the results onto the
fakeRequestinstance ( in the case of nodejs, a full bypass occurs )
The failed tests might just be a bad state in the browser testing stack. If you had them passing locally in a browser then we could move further.
Can you add some API documentation? Thanks