B2G/gecko/services/common/tests/unit/test_storage_server.js
/**
 * Helper function to validate an HTTP response from the server.
 */
Helper function to validate an HTTP response from the server.
Helper function to validate an HTTP response from the server .
function validateResponse(response) {
  do_check_true("x-timestamp" in response.headers);
  if ("content-length" in response.headers) {
    let cl = parseInt(response.headers["content-length"]);
    if (cl != 0) {
      do_check_true("content-type" in response.headers);
      do_check_eq("application/json", response.headers["content-type"]);
    }
  }
  if (response.status == 204 || response.status == 304) {
    do_check_false("content-type" in response.headers);
    if ("content-length" in response.headers) {
      do_check_eq(response.headers["content-length"], "0");
    }
  }
  if (response.status == 405) {
    do_check_true("allow" in response.headers);
  }
}
function validateResponse ( response ) { do_check_true ( "x-timestamp" in response . headers ) ; if ( "content-length" in response . headers ) { let cl = parseInt ( response . headers [ "content-length" ] ) ; if ( cl != 0 ) { do_check_true ( "content-type" in response . headers ) ; do_check_eq ( "application/json" , response . headers [ "content-type" ] ) ; } } if ( response . status == 204 || response . status == 304 ) { do_check_false ( "content-type" in response . headers ) ; if ( "content-length" in response . headers ) { do_check_eq ( response . headers [ "content-length" ] , "0" ) ; } } if ( response . status == 405 ) { do_check_true ( "allow" in response . headers ) ; } }
Helper function to validate an HTTP response from the server.
Helper function to validate an HTTP response from the server .