Branch: Tag:

2001-06-23

2001-06-23 21:42:56 by Martin Nilsson <mani@lysator.liu.se>

Print out some more useful information when any http test fails.

Rev: server/etc/test/tests/http/http_common.pike:1.5

59:    }   }    + #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;
82:    }       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 );   }