sendOneAttempt_(request) {
    return new Promise((resolve, reject) => {
      const xhr = new XMLHttpRequest();
      xhr.onreadystatechange = () => {
        if (xhr.readyState == XMLHttpRequest.DONE) {
          resolve(xhr);
        }
      };

      xhr.timeout = request.timeoutMillis;
      xhr.ontimeout = () => {
        reject(new Error('Timed out'));
      };

      xhr.open(request.method, request.url, true);
      if (request.headers == null) {
        xhr.setRequestHeader(
            'Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
      } else {
        request.headers.forEach(
            header => xhr.setRequestHeader(header[0], header[1]));
      }
      xhr.responseType = request.responseType;
      xhr.send(request.body);
    });
  }
/**
   * Executes a XMLHttpRequest and returns a Promise that resolves with the
   * response, or rejects if the request times out.
   * @param {!QueueEntry_} request
   * @return {!Promise<!XMLHttpRequest>} Resolves with the response. Rejects if
   *     the request timed out.
   * @private
   */
Executes a XMLHttpRequest and returns a Promise that resolves with the
response, or rejects if the request times out.
@param {!QueueEntry_} request
@return {!Promise} Resolves with the response. Rejects if
the request timed out.
@private
Executes a XMLHttpRequest and returns a Promise that resolves with the response or rejects if the request times out . @param { !QueueEntry_ } request @return { !Promise } Resolves with the response . Rejects if the request timed out . @private
sendOneAttempt_(request) {
    return new Promise((resolve, reject) => {
      const xhr = new XMLHttpRequest();
      xhr.onreadystatechange = () => {
        if (xhr.readyState == XMLHttpRequest.DONE) {
          resolve(xhr);
        }
      };
      xhr.timeout = request.timeoutMillis;
      xhr.ontimeout = () => {
        reject(new Error('Timed out'));
      };
      xhr.open(request.method, request.url, true);
      if (request.headers == null) {
        xhr.setRequestHeader(
            'Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
      } else {
        request.headers.forEach(
            header => xhr.setRequestHeader(header[0], header[1]));
      }
      xhr.responseType = request.responseType;
      xhr.send(request.body);
    });
  }
sendOneAttempt_ ( request ) { return new Promise ( ( resolve , reject ) => { const xhr = new XMLHttpRequest ( ) ; xhr . onreadystatechange = ( ) => { if ( xhr . readyState == XMLHttpRequest . DONE ) { resolve ( xhr ) ; } } ; xhr . timeout = request . timeoutMillis ; xhr . ontimeout = ( ) => { reject ( new Error ( 'Timed out' ) ) ; } ; xhr . open ( request . method , request . url , true ) ; if ( request . headers == null ) { xhr . setRequestHeader ( 'Content-Type' , 'application/x-www-form-urlencoded;charset=utf-8' ) ; } else { request . headers . forEach ( header => xhr . setRequestHeader ( header [ 0 ] , header [ 1 ] ) ) ; } xhr . responseType = request . responseType ; xhr . send ( request . body ) ; } ) ; }
Executes a XMLHttpRequest and returns a Promise that resolves with the
 response, or rejects if the request times out.
Executes a XMLHttpRequest and returns a Promise that resolves with the response or rejects if the request times out .