Roxen.git / server / etc / test / tests / http / http_common.pike

version» Context lines:

Roxen.git/server/etc/test/tests/http/http_common.pike:12:   // 10 is error-in-execution from pike.   constant HEADERS = 11;   constant DATA = 12;   constant CONN = 13;      constant TIMEOUT = 99;   constant BADARG = 100;      void setup_timeout( )   { -  void timeout() { exit( TIMEOUT ); }; +    #ifndef __NT__ -  +  void timeout() { exit( TIMEOUT ); };    signal( 14, timeout ); -  alarm( 5 ); +  alarm( 30 );   #endif   }      array get_host_port( string url )   {    string host;    int port;       if( sscanf( url, "http://%s:%d/", host, port ) != 2 )    exit( BADARG );
Roxen.git/server/etc/test/tests/http/http_common.pike:52:    string what,    int chars )   {    foreach( what/((float)chars), string w )    {    to->write( w );    sleep( 0.01 );    }   }    + #define EXIT(X) while(1){write("\n\n\nThe offending response header:\n%O\n\n" \ +  "Protocol: %O (%O)\n" \ +  "Return code: %d (%d)\n" \ +  "Response mapping: %O\n", \ +  headers,prot,expected_prot, \ +  code,expected_code,hd);exit((X));}      void verify_headers( string headers, int content_length,    string expected_prot, int expected_code, -  int want_last_modified ) +  int want_last_modified, )   {    array q = headers / "\r\n";    string prot;    int code;    string message; -  if( sscanf( q[0], "%s %d %s", prot, code, message ) != 3 )exit( BADHEADERS ); -  if( prot != expected_prot ) exit( BADPROT ); -  if( code != expected_code ) exit( BADCODE ); +  mapping hd = ([]);    -  +  if( sscanf( q[0], "%s %d %s", prot, code, message ) != 3 ) EXIT( BADHEADERS ); +  if( prot != expected_prot ) EXIT( BADPROT ); +  if( code != expected_code ) EXIT( BADCODE );    -  mapping hd = ([]); +     foreach( q[1..], string header )    {    string a, b;    sscanf( header, "%s: %s", a, b );    hd[ lower_case( a ) ] = b;    }       if( !hd->date ) -  exit( NODATE ); +  EXIT( NODATE );    if( !hd["content-length"] || (int)hd["content-length"] != content_length ) -  exit( BADLENGTH ); +  EXIT( BADLENGTH );    if( want_last_modified && !hd["last-modified"] ) -  exit( BADMODIFIED ); +  EXIT( BADMODIFIED );   }