File: headerparser003.phpt

package info (click to toggle)
php-pecl-http 3.1.0%2B2.6.0-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,060 kB
  • ctags: 3,725
  • sloc: ansic: 37,486; xml: 818; php: 635; pascal: 164; makefile: 2
file content (54 lines) | stat: -rw-r--r-- 799 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
--TEST--
header parser with nonblocking stream
--SKIPIF--
<?php 
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";

$parser = new http\Header\Parser;
$socket = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
stream_set_blocking($socket[0], 0);

$headers = array(
"GET / HTTP/1.1\n",
"Host: localhost","\n",
"Content","-length: 3\n",
"\n",
);

while ($headers) {
	$line = array_shift($headers);
	$parser->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