B2G/gecko/netwerk/test/httpserver/test/head_utils.js
/**
 * Sends a raw string of bytes to the given host and port and checks that the
 * response is acceptable.
 *
 * @param host : string
 *   the host to which a connection should be made
 * @param port : PRUint16
 *   the port to use for the connection
 * @param data : string or [string...]
 *   either:
 *     - the raw data to send, as a string of characters with codes in the
 *       range 0-255, or
 *     - an array of such strings whose concatenation forms the raw data
 * @param responseCheck : function(string) : void
 *   a function which is provided with the data sent by the remote host which
 *   conducts whatever tests it wants on that data; useful for tweaking the test
 *   environment between tests
 */
Sends a raw string of bytes to the given host and port and checks that the
response is acceptable.


Sends a raw string of bytes to the given host and port and checks that the response is acceptable .
function RawTest(host, port, data, responseCheck)
{
  if (0 > port || 65535 < port || port % 1 !== 0)
    throw "bad port";
  if (!(data instanceof Array))
    data = [data];
  if (data.length <= 0)
    throw "bad data length";
  if (!data.every(function(v) { return /^[\x00-\xff]*$/.test(v); }))
    throw "bad data contained non-byte-valued character";
  this.host = host;
  this.port = port;
  this.data = data;
  this.responseCheck = responseCheck;
}
function RawTest ( host , port , data , responseCheck ) { if ( 0 > port || 65535 < port || port % 1 !== 0 ) throw "bad port" ; if ( ! ( data instanceof Array ) ) data = [ data ] ; if ( data . length <= 0 ) throw "bad data length" ; if ( ! data . every ( function ( v ) { return / ^[\x00-\xff]*$ / . test ( v ) ; } ) ) throw "bad data contained non-byte-valued character" ; this . host = host ; this . port = port ; this . data = data ; this . responseCheck = responseCheck ; }
Sends a raw string of bytes to the given host and port and checks that the
 response is acceptable.
Sends a raw string of bytes to the given host and port and checks that the response is acceptable .