code: function parseHttpResponse(command, httpResponse) {
    if (httpResponse.status < 200) {
      // This should never happen, but throw the raw response so users report it.
      throw new error.WebDriverError(
          `Unexpected HTTP response:\n${httpResponse}`);
    }
  
    let parsed = tryParse(httpResponse.body);
    if (parsed && typeof parsed === 'object') {
      let value = parsed.value;
      let isW3C =
          value !== null && typeof value === 'object'
              && typeof parsed.status === 'undefined';
  
      if (!isW3C) {
        error.checkLegacyResponse(parsed);
  
        // Adjust legacy new session responses to look like W3C to simplify
        // later processing.
        if (command.getName() === cmd.Name.NEW_SESSION) {
          value = parsed;
        }
  
      } else if (httpResponse.status > 399) {
        error.throwDecodedError(value);
      }
  
      return {isW3C, value};
    }
  
    if (parsed !== undefined) {
      return {isW3C: false, value: parsed};
    }
  
    let value = httpResponse.body.replace(/\r\n/g, '\n');
  
    // 404 represents an unknown command; anything else > 399 is a generic unknown
    // error.
    if (httpResponse.status == 404) {
      throw new error.UnsupportedOperationError(command.getName() + ': ' + value);
    } else if (httpResponse.status >= 400) {
      throw new error.WebDriverError(value);
    }
  
    return {isW3C: false, value: value || null};
  }
docs: Callback used to parse {@link Response} objects from a
  {@link HttpClient}.
  
  @param {!cmd.Command} command The command the response is for.
  @param {!Response} httpResponse The HTTP response to parse.
  @return {{isW3C: boolean, value: ?}} An object describing the parsed
  response. This object will have two fields: `isW3C` indicates whether
  the response looks like it came from a remote end that conforms with the
  W3C WebDriver spec, and `value`, the actual response value.
  @throws {WebDriverError} If the HTTP response is an error.