1169d92004-05-02Martin Nilsson START_MARKER
05dc762001-07-20Martin Stjernholm 
39a7012004-01-27Martin Nilsson test_eq(_Roxen.html_encode_string (0), "0") test_eq(_Roxen.html_encode_string (""), "") test_eq(_Roxen.html_encode_string (10), "10") test_eq(_Roxen.html_encode_string("a&b<c>d"), "a&amp;b&lt;c&gt;d")
a4afff2012-07-06Martin Stjernholm test_eq((int) _Roxen.html_encode_string (Int.NATIVE_MAX), Int.NATIVE_MAX); test_eq((int) _Roxen.html_encode_string (Int.NATIVE_MIN + 1), Int.NATIVE_MIN + 1); test_eq((int) _Roxen.html_encode_string (Int.NATIVE_MIN), Int.NATIVE_MIN);
39a7012004-01-27Martin Nilsson  test_eq(_Roxen.http_decode_string(""), "") test_eq(_Roxen.http_decode_string("abc+d%20e%41"), "abc+d eA") test_eq(_Roxen.http_decode_string(""), "")
c5d8892014-10-17Henrik Grubbström (Grubba) test_eq(_Roxen.http_decode_string("+"), "+") // The following inputs are all illegal, but are allowed // for compat reasons. test_eq(_Roxen.http_decode_string("%"), "\0") test_eq(_Roxen.http_decode_string("%0"), "\0") test_eq(_Roxen.http_decode_string("%%"), "\0") test_eq(_Roxen.http_decode_string("%%%"), "U") test_eq(_Roxen.http_decode_string("%41%"), "A\0") test_eq(_Roxen.http_decode_string("%41%0"), "A\0") test_eq(_Roxen.http_decode_string("%41%%"), "A\0") test_eq(_Roxen.http_decode_string("%41%%%"), "AU") test_eq(_Roxen.http_decode_string("%u"), "\0") test_eq(_Roxen.http_decode_string("%u0"), "\0") test_eq(_Roxen.http_decode_string("%u00"), "\0") test_eq(_Roxen.http_decode_string("%u000"), "\0") test_eq(_Roxen.http_decode_string("%u000_"), "\b") test_eq(_Roxen.http_decode_string("%41%u"), "A\0") test_eq(_Roxen.http_decode_string("%41%u0"), "A\0") test_eq(_Roxen.http_decode_string("%41%u00"), "A\0") test_eq(_Roxen.http_decode_string("%41%u000"), "A\0") test_eq(_Roxen.http_decode_string("%41%u000_"), "A\b")
39a7012004-01-27Martin Nilsson test_eq(_Roxen.http_decode_string("%u12345"), "\x1234""5") test_eq(_Roxen.http_decode_string("%U12345"), "\x1234""5")
7113c02004-01-27Martin Nilsson  define(test_mkhttp,[[ test_any_equal([[ string x=_Roxen.make_http_headers($1); if(!has_suffix(x, "\r\n")) return -1; return sort(x/"\r\n"-({""})); ]],$2) ]]) test_eval_error(_Roxen.make_http_headers(0)) test_mkhttp( ([]), ({}) ) test_mkhttp( (["":""]), ({": "}) ) test_mkhttp( (["a":"1","b":"2"]), ({"a: 1","b: 2"}) ) test_mkhttp( (["a":"1","b":({"2","3"})]), ({"a: 1","b: 2","b: 3"}) ) test_mkhttp( (["a":"1","b":({"2","2"})]), ({"a: 1","b: 2","b: 2"}) )
f2225c2009-07-29Martin Nilsson  define(test_hp,[[ test_do( add_constant("hp", _Roxen.HeaderParser()) ) test_equal( hp->feed( $1 ), $2) test_do( add_constant("hp") ) ]]) test_hp( "GET / HTTP/1.0\r\nblaha: foo\nbar\r\nzonk: 1\r\n\r\n", ({ "", "GET / HTTP/1.0", ([ "blaha":"foo", "zonk":"1" ]) }) ) test_hp( "GET / HTTP/1.0\r\nblaha: foo\r\nzonk: 1\r\n\r\n", ({ "", "GET / HTTP/1.0", ([ "blaha":"foo", "zonk":"1" ]) }) ) test_hp( "GET / HTTP/1.0\r\nblaha: foo\n\rblaha: bar\r\n\r\n", ({ "", "GET / HTTP/1.0", ([ "blaha":({ "foo", "bar" }) ]) }) )
1169d92004-05-02Martin Nilsson END_MARKER