From 4f92a2983270a1fa41e400ff970576161baba5e6 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Tue, 17 Feb 2015 14:30:38 +0100 Subject: [PATCH] test header parser errors and streaming --- tests/headerparser002.phpt | 59 ++++++++++++++++++++++++++++++++++++++ tests/headerparser003.phpt | 54 ++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 tests/headerparser002.phpt create mode 100644 tests/headerparser003.phpt diff --git a/tests/headerparser002.phpt b/tests/headerparser002.phpt new file mode 100644 index 0000000..c5a02f1 --- /dev/null +++ b/tests/headerparser002.phpt @@ -0,0 +1,59 @@ +--TEST-- +header parser errors +--SKIPIF-- + +--FILE-- +parse($header, http\Header\Parser::CLEANUP, $parsed), $parsed); +} +?> +===DONE=== +--EXPECTF-- +Test + +Warning: http\Header\Parser::parse(): Failed to parse headers: unexpected character '\000' at pos 2 of 'Na\000me' in %sheaderparser002.php on line %d +int(-1) +array(0) { +} + +Warning: http\Header\Parser::parse(): Failed to parse headers: unexpected end of line at pos 2 of 'Na\nme: value' in %sheaderparser002.php on line %d +int(-1) +array(0) { +} + +Warning: http\Header\Parser::parse(): Failed to parse headers: unexpected character '\000' at pos 0 of '\000value' in %sheaderparser002.php on line %d +int(-1) +array(0) { +} + +Warning: http\Header\Parser::parse(): Failed to parse headers: unexpected end of input at pos 5 of 'value' in %sheaderparser002.php on line %d +int(-1) +array(0) { +} + +Warning: http\Header\Parser::parse(): Failed to parse headers: unexpected character '\000' at pos 3 of 'val\000ue' in %sheaderparser002.php on line %d +int(-1) +array(0) { +} + +Warning: http\Header\Parser::parse(): Failed to parse headers: unexpected character '\000' at pos 5 of 'value\000' in %sheaderparser002.php on line %d +int(-1) +array(0) { +} +===DONE=== \ No newline at end of file diff --git a/tests/headerparser003.phpt b/tests/headerparser003.phpt new file mode 100644 index 0000000..e1954e7 --- /dev/null +++ b/tests/headerparser003.phpt @@ -0,0 +1,54 @@ +--TEST-- +header parser with nonblocking stream +--SKIPIF-- + +--FILE-- +stream($socket[0], 0, $hdrs); + fwrite($socket[1], $line); + var_dump($parser->getState()); + var_dump($parser->stream($socket[0], 0, $hdrs)); +} + +var_dump($hdrs); + +?> +DONE +--EXPECT-- +Test +int(0) +int(1) +int(1) +int(2) +int(2) +int(3) +int(3) +int(1) +int(1) +int(3) +int(3) +int(5) +array(2) { + ["Host"]=> + string(9) "localhost" + ["Content-Length"]=> + string(1) "3" +} +DONE -- 2.30.2