3ad2d52001-02-01Per Hedbor inherit "http_common"; void main(int argc, array argv) {
136c032001-02-20Per Hedbor  string sep = "\r\n";
8ff16a2001-10-02Per Hedbor  int psize = 100000, hlen; int fail;
136c032001-02-20Per Hedbor  if( argc < 4 ) exit( BADARG ); if( argc == 5 ) { switch( (int)argv[4] ) { case 1: break; case 2: sep = "\n"; break; case 3: psize = 1; break; case 4: psize = 10; break;
8ff16a2001-10-02Per Hedbor  case 5: hlen = 1024; break; case 6: hlen = 10240; break; case 7: hlen = 102400; break; case 8: hlen = 1024; sep = "\n"; break; case 9: hlen = 10240; sep = "\n"; break; case 10: sep = "\n"; hlen = 102400; break; case 11: sep = "\n"; hlen = 1024000; fail=1; break;
136c032001-02-20Per Hedbor  } }
3ad2d52001-02-01Per Hedbor  Stdio.File f = connect( argv[1] );
8ff16a2001-10-02Per Hedbor  string extra_headers=""; while( strlen( extra_headers )+100 < hlen ) extra_headers += "Extra-Headers: Filler"+sep;
7fc4a92001-06-24Martin Nilsson  write_fragmented( f,
136c032001-02-20Per Hedbor  "GET "+argv[2]+" HTTP/1.0"+sep+ "Connection: close"+sep+
8ff16a2001-10-02Per Hedbor  extra_headers+
bd02052001-09-25Martin Nilsson  "User-Agent: Roxen Testscript"+sep+sep,
136c032001-02-20Per Hedbor  psize );
3ad2d52001-02-01Per Hedbor  string _d = f->read();
2d6bf32001-10-04Marcus Wellhardh  if ( !_d ) if(!fail) _d = "HTTP/1.0 500 Internal Server Error\r\n"; else exit( OK );
3ad2d52001-02-01Per Hedbor  array q = _d/"\r\n\r\n"; if( sizeof( q ) < 2 ) exit( BADHEADERS );
a3d6892001-02-01Per Hedbor  verify_headers( q[0], strlen(q[1]), "HTTP/1.0",
8ff16a2001-10-02Per Hedbor  (fail?500:(argv[2] != "/nofile" ? 200 : 404)), !fail && (argv[2][strlen(argv[2])-3..]=="raw"));
3ad2d52001-02-01Per Hedbor  if( (int)argv[3] ) if( q[1] != ("\0" * (int)argv[3]) ) exit( BADDATA ); exit( OK ); }