pike.git / src / modules / _Roxen / testsuite.in

version» Context lines:

pike.git/src/modules/_Roxen/testsuite.in:59:   test_eval_error(_Roxen.make_http_headers((["a\rb": "1"])))   test_eval_error(_Roxen.make_http_headers((["a\nb": "1"])))   test_eval_error(_Roxen.make_http_headers(([" a:1": "1"])))   test_eval_error(_Roxen.make_http_headers((["a": "1\r"])))   test_eval_error(_Roxen.make_http_headers((["a": "1\n"])))   test_eval_error(_Roxen.make_http_headers((["a": ({ "1\r\nb:2", "2\r\nc:2" })))))      define(test_hp,[[    test_any_equal([[    object hp = _Roxen.HeaderParser(); +  if( $2[0]=="" ) +  { +  // Only feed in increments when we are not testing trailing data. +  Stdio.Buffer data = Stdio.Buffer($1); +  while( sizeof(data) ) +  { +  mixed res = hp->feed(data->read(1)); +  if(res) return res; +  } +  return -1; +  }    return hp->feed( $1 );    ]], $2) -  +  test_any_equal([[ +  object hp = _Roxen.HeaderParser(); +  if( $2[0]=="" ) +  { +  // Only feed in increments when we are not testing trailing data. +  Stdio.Buffer data = Stdio.Buffer($1); +  while( sizeof(data) ) +  { +  string s = data->read(random(3)); +  if(!s) s = data->read(1); +  mixed res = hp->feed(s); +  if(res) return res; +  } +  return -1; +  } +  return hp->feed( $1 ); +  ]], $2)   ]])      test_hp( "GET / HTTP/1.0\r\n\r\n",   ({ "", "GET / HTTP/1.0", ([]) }))      test_hp( "GET / HTTP/1.0\r\n\r\nDATA",   ({ "DATA", "GET / HTTP/1.0", ([]) }))      test_hp( "GET / HTTP/1.0\r\nhdr: 1\r\n\r\nDATA",   ({ "DATA", "GET / HTTP/1.0", ([ "hdr":"1"]) }))