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

version» Context lines:

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\nReturn code: %d (%d)\nResponse mapping: %O\n", \ +  headers,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 );   }