X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=tests%2Fheaderparser001.phpt;fp=tests%2Fheaderparser001.phpt;h=0a1eb37ad676a5c31db57d9b5ed7729e3ad6db82;hp=0000000000000000000000000000000000000000;hb=629c7b270b047582160c87b7c688c2b942a75d60;hpb=8573aba3509b1b6eb197ae59d32ca7c81bfe957e diff --git a/tests/headerparser001.phpt b/tests/headerparser001.phpt new file mode 100644 index 0000000..0a1eb37 --- /dev/null +++ b/tests/headerparser001.phpt @@ -0,0 +1,61 @@ +--TEST-- +header parser +--SKIPIF-- + +--FILE-- +"FAILURE",0=>"START","KEY","VALUE","VALUE_EX","HEADER_DONE","DONE"]; +$parser = new http\Header\Parser; +do { + $state = $parser->parse($part = array_shift($headers), + $headers ? 0 : http\Header\Parser::CLEANUP, + $result); + printf("%2\$-32s | %1\$s\n", $states[$state], addcslashes($part, "\r\n\t\0")); +} while ($headers && $state !== http\Header\Parser::STATE_FAILURE); + +var_dump($result); + +?> +===DONE=== +--EXPECT-- +Test +One: | VALUE +header\n | VALUE_EX +Two: header\n\tlines\n | VALUE_EX +Three | KEY +: header\n lines\n here\n | VALUE_EX +More: than one header\n | VALUE_EX +More: | VALUE +than: | VALUE +you: | VALUE +expect\n | VALUE_EX +\n | DONE +array(4) { + ["One"]=> + string(6) "header" + ["Two"]=> + string(12) "header lines" + ["Three"]=> + string(17) "header lines here" + ["More"]=> + array(2) { + [0]=> + string(15) "than one header" + [1]=> + string(17) "than: you: expect" + } +} +===DONE===