temp/www/build/bundle.js
/**
         * Creates the XHR object and sends the request.
         *
         * @api private
         */
Creates the XHR object and sends the request.
@api private
Creates the XHR object and sends the request . @api private
create() {
            const opts = pick(this.opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
            opts.xdomain = !!this.opts.xd;
            opts.xscheme = !!this.opts.xs;
            const xhr = (this.xhr = new XMLHttpRequest$1(opts));
            try {
                xhr.open(this.method, this.uri, this.async);
                try {
                    if (this.opts.extraHeaders) {
                        xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true);
                        for (let i in this.opts.extraHeaders) {
                            if (this.opts.extraHeaders.hasOwnProperty(i)) {
                                xhr.setRequestHeader(i, this.opts.extraHeaders[i]);
                            }
                        }
                    }
                }
                catch (e) { }
                if ("POST" === this.method) {
                    try {
                        xhr.setRequestHeader("Content-type", "text/plain;charset=UTF-8");
                    }
                    catch (e) { }
                }
                try {
                    xhr.setRequestHeader("Accept", "*/*");
                }
                catch (e) { }
                if ("withCredentials" in xhr) {
                    xhr.withCredentials = this.opts.withCredentials;
                }
                if (this.opts.requestTimeout) {
                    xhr.timeout = this.opts.requestTimeout;
                }
                xhr.onreadystatechange = () => {
                    if (4 !== xhr.readyState)
                        return;
                    if (200 === xhr.status || 1223 === xhr.status) {
                        this.onLoad();
                    }
                    else {
                        this.setTimeoutFn(() => {
                            this.onError(typeof xhr.status === "number" ? xhr.status : 0);
                        }, 0);
                    }
                };
                xhr.send(this.data);
            }
            catch (e) {
                this.setTimeoutFn(() => {
                    this.onError(e);
                }, 0);
                return;
            }
            if (typeof document !== "undefined") {
                this.index = Request.requestsCount++;
                Request.requests[this.index] = this;
            }
        }
create ( ) { const opts = pick ( this . opts , "agent" , "pfx" , "key" , "passphrase" , "cert" , "ca" , "ciphers" , "rejectUnauthorized" , "autoUnref" ) ; opts . xdomain = ! ! this . opts . xd ; opts . xscheme = ! ! this . opts . xs ; const xhr = ( this . xhr = new XMLHttpRequest$1 ( opts ) ) ; try { xhr . open ( this . method , this . uri , this . async ) ; try { if ( this . opts . extraHeaders ) { xhr . setDisableHeaderCheck && xhr . setDisableHeaderCheck ( true ) ; for ( let i in this . opts . extraHeaders ) { if ( this . opts . extraHeaders . hasOwnProperty ( i ) ) { xhr . setRequestHeader ( i , this . opts . extraHeaders [ i ] ) ; } } } } catch ( e ) { } if ( "POST" === this . method ) { try { xhr . setRequestHeader ( "Content-type" , "text/plain;charset=UTF-8" ) ; } catch ( e ) { } } try { xhr . setRequestHeader ( "Accept" , "*/*" ) ; } catch ( e ) { } if ( "withCredentials" in xhr ) { xhr . withCredentials = this . opts . withCredentials ; } if ( this . opts . requestTimeout ) { xhr . timeout = this . opts . requestTimeout ; } xhr . onreadystatechange = ( ) => { if ( 4 !== xhr . readyState ) return ; if ( 200 === xhr . status || 1223 === xhr . status ) { this . onLoad ( ) ; } else { this . setTimeoutFn ( ( ) => { this . onError ( typeof xhr . status === "number" ? xhr . status : 0 ) ; } , 0 ) ; } } ; xhr . send ( this . data ) ; } catch ( e ) { this . setTimeoutFn ( ( ) => { this . onError ( e ) ; } , 0 ) ; return ; } if ( typeof document !== "undefined" ) { this . index = Request . requestsCount ++ ; Request . requests [ this . index ] = this ; } }
Creates the XHR object and sends the request.
Creates the XHR object and sends the request .
// ie6 check // make sure the `error` event handler that's user-set // does not throw in the same tick and gets caught here // Need to defer since .create() is called directly from the constructor // and thus the 'error' event can only be only bound *after* this exception // occurs.  Therefore, also, we cannot throw here at all.