Branch: Tag:

2001-02-01

2001-02-01 08:36:45 by Per Hedbor <ph@opera.com>

More HTTP tests.

Rev: server/etc/test/tests/http/RoxenTest_http.pike:1.2
Rev: server/etc/test/tests/http/http09.pike:1.2
Rev: server/etc/test/tests/http/http10.pike:1.2
Rev: server/etc/test/tests/http/http_common.pike:1.2
Rev: server/etc/test/tests/http/ping.pike:1.1
Rev: server/etc/test/tests/pike_async_process_test_common.pike:1.2

4:   constant BADDATA = 3;   constant NOCONN = 4;    + constant BADPROT = 5; + constant BADCODE = 6; + constant NODATE = 7; + constant BADLENGTH = 8; + constant BADMODIFIED= 9; +    constant HEADERS = 11;   constant DATA = 12;   constant CONN = 13;
43:   }       - void verify_headers( string headers, int content_length ) + void verify_headers( string headers, int content_length, +  string expected_prot, int expected_code, +  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 = ([]); +  foreach( q[1..], string header ) +  { +  string a, b; +  sscanf( header, "%s: %s", a, b ); +  hd[ lower_case( a ) ] = b;    }    -  +  if( !hd->date ) +  exit( NODATE ); +  if( !hd["content-length"] || (int)hd["content-length"] != content_length ) +  exit( BADLENGTH ); +  if( want_last_modified && !hd["last-modified"] ) +  exit( BADMODIFIED ); + } +