Allow custom xhr factory similar to jQuery.

This allows users to supply a custom `xhr` factory.
My use case is to integrate [pmxdr](https://github.com/eligrey/libxdr), but this is flexible enough for other use cases.

At first glance, this would also allow to easily mock XmlHttpRequest compatible instances in tests.