dist/client/lance-gg.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$1(
        this.opts,
        "agent",
        "enablesXDR",
        "pfx",
        "key",
        "passphrase",
        "cert",
        "ca",
        "ciphers",
        "rejectUnauthorized"
      );
      opts.xdomain = !!this.opts.xd;
      opts.xscheme = !!this.opts.xs;
      const xhr = (this.xhr = new xmlhttprequest(opts));
      const self = this;
      try {
        debug$1("xhr open %s: %s", this.method, this.uri);
        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;
        }
        if (this.hasXDR()) {
          xhr.onload = function() {
            self.onLoad();
          };
          xhr.onerror = function() {
            self.onError(xhr.responseText);
          };
        } else {
          xhr.onreadystatechange = function() {
            if (4 !== xhr.readyState) return;
            if (200 === xhr.status || 1223 === xhr.status) {
              self.onLoad();
            } else {
              setTimeout(function() {
                self.onError(typeof xhr.status === "number" ? xhr.status : 0);
              }, 0);
            }
          };
        }
        debug$1("xhr data %s", this.data);
        xhr.send(this.data);
      } catch (e) {
        setTimeout(function() {
          self.onError(e);
        }, 0);
        return;
      }
      if (typeof document !== "undefined") {
        this.index = Request.requestsCount++;
        Request.requests[this.index] = this;
      }
    }
create ( ) { const opts = pick$1 ( this . opts , "agent" , "enablesXDR" , "pfx" , "key" , "passphrase" , "cert" , "ca" , "ciphers" , "rejectUnauthorized" ) ; opts . xdomain = ! ! this . opts . xd ; opts . xscheme = ! ! this . opts . xs ; const xhr = ( this . xhr = new xmlhttprequest ( opts ) ) ; const self = this ; try { debug$1 ( "xhr open %s: %s" , this . method , this . uri ) ; 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 ; } if ( this . hasXDR ( ) ) { xhr . onload = function ( ) { self . onLoad ( ) ; } ; xhr . onerror = function ( ) { self . onError ( xhr . responseText ) ; } ; } else { xhr . onreadystatechange = function ( ) { if ( 4 !== xhr . readyState ) return ; if ( 200 === xhr . status || 1223 === xhr . status ) { self . onLoad ( ) ; } else { setTimeout ( function ( ) { self . onError ( typeof xhr . status === "number" ? xhr . status : 0 ) ; } , 0 ) ; } } ; } debug$1 ( "xhr data %s" , this . data ) ; xhr . send ( this . data ) ; } catch ( e ) { setTimeout ( function ( ) { self . 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.