Test Failure Report for ext/standard/tests/http/ignore_errors.phpt ('http:// and ignore_errors')
Script
1:
<?php 2: require 'server.inc'; 3: 4: function do_test($context_options) { 5: 6: $context = stream_context_create(array('http' => $context_options)); 7: 8: $responses = array( 9: "data://text/plain,HTTP/1.0 200 Ok\r\nX-Foo: bar\r\n\r\n1", 10: "data://text/plain,HTTP/1.0 404 Not found\r\nX-bar: baz\r\n\r\n2", 11: ); 12: 13: $pid = http_server("tcp://127.0.0.1:12342", $responses, $output); 14: 15: foreach($responses as $r) { 16: 17: $fd = fopen('http://127.0.0.1:12342/foo/bar', 'rb', false, $context); 18: var_dump($fd); 19: 20: if ($fd) { 21: $meta_data = stream_get_meta_data($fd); 22: var_dump($meta_data['wrapper_data']); 23: 24: var_dump(stream_get_contents($fd)); 25: } 26: 27: fseek($output, 0, SEEK_SET); 28: var_dump(stream_get_contents($output)); 29: fseek($output, 0, SEEK_SET); 30: } 31: 32: http_server_kill($pid); 33: } 34: 35: echo "-- Test: requests without ignore_errors --\n"; 36: 37: do_test(array()); 38: 39: echo "-- Test: requests with ignore_errors --\n"; 40: 41: do_test(array('ignore_errors' => true)); 42: 43: echo "-- Test: requests with ignore_errors (2) --\n"; 44: 45: do_test(array('ignore_errors' => 1)); 46: 47: ?> 48:
Expected
-- Test: requests without ignore_errors --
resource(%d) of type (stream)
array(2) {
[0]=>
string(15) "HTTP/1.0 200 Ok"
[1]=>
string(10) "X-Foo: bar"
}
string(1) "1"
string(48) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
"
Warning: fopen(http://127.0.0.1:12342/foo/bar): failed to open stream: HTTP request failed! HTTP/1.0 404 Not found
in %s on line %d
bool(false)
string(48) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
"
-- Test: requests with ignore_errors --
resource(%d) of type (stream)
array(2) {
[0]=>
string(15) "HTTP/1.0 200 Ok"
[1]=>
string(10) "X-Foo: bar"
}
string(1) "1"
string(48) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
"
resource(%d) of type (stream)
array(2) {
[0]=>
string(22) "HTTP/1.0 404 Not found"
[1]=>
string(10) "X-bar: baz"
}
string(1) "2"
string(48) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
"
-- Test: requests with ignore_errors (2) --
resource(%d) of type (stream)
array(2) {
[0]=>
string(15) "HTTP/1.0 200 Ok"
[1]=>
string(10) "X-Foo: bar"
}
string(1) "1"
string(48) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
"
resource(%d) of type (stream)
array(2) {
[0]=>
string(22) "HTTP/1.0 404 Not found"
[1]=>
string(10) "X-bar: baz"
}
string(1) "2"
string(48) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
"
Output
-- Test: requests without ignore_errors --
resource(9) of type (stream)
array(2) {
["headers"]=>
array(0) {
}
["readbuf"]=>
resource(10) of type (stream)
}
string(1) "1"
string(89) "GET /foo/bar HTTP/1.1
User-Agent: PHP/5.3.26-dev
Host: 127.0.0.1:12342
Accept: */*
"
resource(12) of type (stream)
array(2) {
["headers"]=>
array(0) {
}
["readbuf"]=>
resource(13) of type (stream)
}
string(1) "2"
string(89) "GET /foo/bar HTTP/1.1
User-Agent: PHP/5.3.26-dev
Host: 127.0.0.1:12342
Accept: */*
"
-- Test: requests with ignore_errors --
resource(18) of type (stream)
array(2) {
["headers"]=>
array(0) {
}
["readbuf"]=>
resource(19) of type (stream)
}
string(1) "1"
string(89) "GET /foo/bar HTTP/1.1
User-Agent: PHP/5.3.26-dev
Host: 127.0.0.1:12342
Accept: */*
"
resource(21) of type (stream)
array(2) {
["headers"]=>
array(0) {
}
["readbuf"]=>
resource(22) of type (stream)
}
string(1) "2"
string(89) "GET /foo/bar HTTP/1.1
User-Agent: PHP/5.3.26-dev
Host: 127.0.0.1:12342
Accept: */*
"
-- Test: requests with ignore_errors (2) --
resource(27) of type (stream)
array(2) {
["headers"]=>
array(0) {
}
["readbuf"]=>
resource(28) of type (stream)
}
string(1) "1"
string(89) "GET /foo/bar HTTP/1.1
User-Agent: PHP/5.3.26-dev
Host: 127.0.0.1:12342
Accept: */*
"
resource(30) of type (stream)
array(2) {
["headers"]=>
array(0) {
}
["readbuf"]=>
resource(31) of type (stream)
}
string(1) "2"
string(89) "GET /foo/bar HTTP/1.1
User-Agent: PHP/5.3.26-dev
Host: 127.0.0.1:12342
Accept: */*
"
Diff
004+ ["headers"]=>
005+ array(0) {
006+ }
007+ ["readbuf"]=>
008+ resource(10) of type (stream)
004- [0]=>
005- string(15) "HTTP/1.0 200 Ok"
006- [1]=>
007- string(10) "X-Foo: bar"
010- string(48) "GET /foo/bar HTTP/1.0
011+ string(89) "GET /foo/bar HTTP/1.1
012+ User-Agent: PHP/5.3.26-dev
014+ Accept: */*
014-
015- Warning: fopen(http://127.0.0.1:12342/foo/bar): failed to open stream: HTTP request failed! HTTP/1.0 404 Not found
016- in %s on line %d
017- bool(false)
018- string(48) "GET /foo/bar HTTP/1.0
017+ resource(12) of type (stream)
018+ array(2) {
019+ ["headers"]=>
020+ array(0) {
021+ }
022+ ["readbuf"]=>
023+ resource(13) of type (stream)
024+ }
025+ string(1) "2"
026+ string(89) "GET /foo/bar HTTP/1.1
027+ User-Agent: PHP/5.3.26-dev
025- [0]=>
026- string(15) "HTTP/1.0 200 Ok"
027- [1]=>
028- string(10) "X-Foo: bar"
029+ Accept: */*
031- string(48) "GET /foo/bar HTTP/1.0
035+ ["headers"]=>
036+ array(0) {
037+ }
038+ ["readbuf"]=>
039+ resource(19) of type (stream)
037- [0]=>
038- string(22) "HTTP/1.0 404 Not found"
039- [1]=>
040- string(10) "X-bar: baz"
042+ string(89) "GET /foo/bar HTTP/1.1
043+ User-Agent: PHP/5.3.26-dev
043- string(48) "GET /foo/bar HTTP/1.0
045+ Accept: */*
050+ ["headers"]=>
051+ array(0) {
052+ }
053+ ["readbuf"]=>
054+ resource(22) of type (stream)
050- [0]=>
051- string(15) "HTTP/1.0 200 Ok"
052- [1]=>
053- string(10) "X-Foo: bar"
056- string(48) "GET /foo/bar HTTP/1.0
057+ string(89) "GET /foo/bar HTTP/1.1
058+ User-Agent: PHP/5.3.26-dev
060+ Accept: */*
062- [0]=>
063- string(22) "HTTP/1.0 404 Not found"
064- [1]=>
065- string(10) "X-bar: baz"
066+ ["headers"]=>
067+ array(0) {
068+ }
069+ ["readbuf"]=>
070+ resource(28) of type (stream)
068- string(48) "GET /foo/bar HTTP/1.0
073+ string(89) "GET /foo/bar HTTP/1.1
074+ User-Agent: PHP/5.3.26-dev
076+ Accept: */*
081+ ["headers"]=>
082+ array(0) {
083+ }
084+ ["readbuf"]=>
085+ resource(31) of type (stream)
088+ string(89) "GET /foo/bar HTTP/1.1
089+ User-Agent: PHP/5.3.26-dev
091+ Accept: */*
Generated at Sun, 12 May 2013 02:17:03 +0000 (6 days ago)
|