prepareResponse(message, response) {
    // IE9 returns status code 1223 instead of 204
    response.status = response.status == 1223 ? 204 : response.status;

    let type;
    let headers = response.headers || {};
    let entity = response.entity;

    if (entity) {
      type = message.responseType();
      if (!type || response.status >= 400) {
        var contentType = headers['content-type'] || headers['Content-Type'];
        if (contentType && contentType.indexOf("application/json") > -1) {
          type = 'json';
        }
      }
    }

    if (headers.etag) {
      headers.etag = headers.etag.replace('--gzip', '');
    }

    if (message.tokenStorage) {
      let token = headers['baqend-authorization-token'] || headers['Baqend-Authorization-Token'];
      if (token) {
        message.tokenStorage.update(token);
      }
    }

    return new Promise((resolve) => {
      resolve(entity && this.fromFormat(response, entity, type));
    }).then((entity) => {
      response.entity = entity;

      if (message.request.path.indexOf('/connect') != -1 && entity) {
        this.gzip = !!entity.gzip;
      }
    }, (e) => {
      throw new Error('Response was not valid ' + type + ': ' + e.message);
    });
  }
/**
   * @param {connector.Message} message
   * @param {Object} response The received response headers and data
   */
@param {connector.Message} message
@param {Object} response The received response headers and data
@param { connector . Message } message @param { Object } response The received response headers and data
prepareResponse(message, response) {
    response.status = response.status == 1223 ? 204 : response.status;
    let type;
    let headers = response.headers || {};
    let entity = response.entity;
    if (entity) {
      type = message.responseType();
      if (!type || response.status >= 400) {
        var contentType = headers['content-type'] || headers['Content-Type'];
        if (contentType && contentType.indexOf("application/json") > -1) {
          type = 'json';
        }
      }
    }
    if (headers.etag) {
      headers.etag = headers.etag.replace('--gzip', '');
    }
    if (message.tokenStorage) {
      let token = headers['baqend-authorization-token'] || headers['Baqend-Authorization-Token'];
      if (token) {
        message.tokenStorage.update(token);
      }
    }
    return new Promise((resolve) => {
      resolve(entity && this.fromFormat(response, entity, type));
    }).then((entity) => {
      response.entity = entity;
      if (message.request.path.indexOf('/connect') != -1 && entity) {
        this.gzip = !!entity.gzip;
      }
    }, (e) => {
      throw new Error('Response was not valid ' + type + ': ' + e.message);
    });
  }
prepareResponse ( message , response ) { response . status = response . status == 1223 ? 204 : response . status ; let type ; let headers = response . headers || { } ; let entity = response . entity ; if ( entity ) { type = message . responseType ( ) ; if ( ! type || response . status >= 400 ) { var contentType = headers [ 'content-type' ] || headers [ 'Content-Type' ] ; if ( contentType && contentType . indexOf ( "application/json" ) > - 1 ) { type = 'json' ; } } } if ( headers . etag ) { headers . etag = headers . etag . replace ( '--gzip' , '' ) ; } if ( message . tokenStorage ) { let token = headers [ 'baqend-authorization-token' ] || headers [ 'Baqend-Authorization-Token' ] ; if ( token ) { message . tokenStorage . update ( token ) ; } } return new Promise ( ( resolve ) => { resolve ( entity && this . fromFormat ( response , entity , type ) ) ; } ) . then ( ( entity ) => { response . entity = entity ; if ( message . request . path . indexOf ( '/connect' ) != - 1 && entity ) { this . gzip = ! ! entity . gzip ; } } , ( e ) => { throw new Error ( 'Response was not valid ' + type + ': ' + e . message ) ; } ) ; }
@param {connector.Message} message
 @param {Object} response The received response headers and data
@param { connector . Message } message @param { Object } response The received response headers and data
// IE9 returns status code 1223 instead of 204