Rewrite xhr shim for XMLHttpRequest2