Test Failure Report for ext/standard/tests/http/bug38802.phpt ('Bug #38802 (ignore_errors and max_redirects)')
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 302 Moved Temporarily\r\nLocation: http://127.0.0.1:12342/foo/bar2\r\n\r\n1", 10: "data://text/plain,HTTP/1.0 301 Moved Permanently\r\nLocation: http://127.0.0.1:12342/foo/bar3\r\n\r\n", 11: "data://text/plain,HTTP/1.0 302 Moved Temporarily\r\nLocation: http://127.0.0.1:12342/foo/bar4\r\n\r\n3", 12: "data://text/plain,HTTP/1.0 200 OK\r\n\r\ndone.", 13: ); 14: 15: $pid = http_server("tcp://127.0.0.1:12342", $responses, $output); 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: 30: http_server_kill($pid); 31: } 32: 33: echo "-- Test: follow all redirections --\n"; 34: 35: do_test(array(), 4); 36: 37: echo "-- Test: fail after 2 redirections --\n"; 38: 39: do_test(array('max_redirects' => 2), 2); 40: 41: echo "-- Test: fail at first redirection --\n"; 42: 43: do_test(array('max_redirects' => 0), 1); 44: 45: echo "-- Test: fail at first redirection (2) --\n"; 46: 47: do_test(array('max_redirects' => 1), 1); 48: 49: echo "-- Test: return at first redirection --\n"; 50: 51: do_test(array('max_redirects' => 0, 'ignore_errors' => 1), 1); 52: 53: echo "-- Test: return at first redirection (2) --\n"; 54: 55: do_test(array('max_redirects' => 1, 'ignore_errors' => 1), 1); 56: 57: echo "-- Test: return at second redirection --\n"; 58: 59: do_test(array('max_redirects' => 2, 'ignore_errors' => 1), 2); 60: 61: ?> 62:
Expected
-- Test: follow all redirections --
resource(%d) of type (stream)
array(7) {
[0]=>
string(30) "HTTP/1.0 302 Moved Temporarily"
[1]=>
string(41) "Location: http://127.0.0.1:12342/foo/bar2"
[2]=>
string(30) "HTTP/1.0 301 Moved Permanently"
[3]=>
string(41) "Location: http://127.0.0.1:12342/foo/bar3"
[4]=>
string(30) "HTTP/1.0 302 Moved Temporarily"
[5]=>
string(41) "Location: http://127.0.0.1:12342/foo/bar4"
[6]=>
string(15) "HTTP/1.0 200 OK"
}
string(5) "done."
string(195) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
GET /foo/bar2 HTTP/1.0
Host: 127.0.0.1:12342
GET /foo/bar3 HTTP/1.0
Host: 127.0.0.1:12342
GET /foo/bar4 HTTP/1.0
Host: 127.0.0.1:12342
"
-- Test: fail after 2 redirections --
Warning: fopen(http://127.0.0.1:12342/foo/bar): failed to open stream: Redirection limit reached, aborting in %s
bool(false)
string(97) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
GET /foo/bar2 HTTP/1.0
Host: 127.0.0.1:12342
"
-- Test: fail at first redirection --
Warning: fopen(http://127.0.0.1:12342/foo/bar): failed to open stream: Redirection limit reached, aborting in %s
bool(false)
string(48) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
"
-- Test: fail at first redirection (2) --
Warning: fopen(http://127.0.0.1:12342/foo/bar): failed to open stream: Redirection limit reached, aborting in %s
bool(false)
string(48) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
"
-- Test: return at first redirection --
resource(%d) of type (stream)
array(2) {
[0]=>
string(30) "HTTP/1.0 302 Moved Temporarily"
[1]=>
string(41) "Location: http://127.0.0.1:12342/foo/bar2"
}
string(1) "1"
string(48) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
"
-- Test: return at first redirection (2) --
resource(%d) of type (stream)
array(2) {
[0]=>
string(30) "HTTP/1.0 302 Moved Temporarily"
[1]=>
string(41) "Location: http://127.0.0.1:12342/foo/bar2"
}
string(1) "1"
string(48) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
"
-- Test: return at second redirection --
resource(%d) of type (stream)
array(4) {
[0]=>
string(30) "HTTP/1.0 302 Moved Temporarily"
[1]=>
string(41) "Location: http://127.0.0.1:12342/foo/bar2"
[2]=>
string(30) "HTTP/1.0 301 Moved Permanently"
[3]=>
string(41) "Location: http://127.0.0.1:12342/foo/bar3"
}
string(0) ""
string(97) "GET /foo/bar HTTP/1.0
Host: 127.0.0.1:12342
GET /foo/bar2 HTTP/1.0
Host: 127.0.0.1:12342
"
Output
-- Test: follow all redirections --
resource(9) of type (stream)
array(2) {
["headers"]=>
array(0) {
}
["readbuf"]=>
resource(10) of type (stream)
}
string(5) "done."
string(359) "GET /foo/bar HTTP/1.1
User-Agent: PHP/5.3.26-dev
Host: 127.0.0.1:12342
Accept: */*
GET /foo/bar2 HTTP/1.0
User-Agent: PHP/5.3.26-dev
Host: 127.0.0.1:12342
Accept: */*
GET /foo/bar3 HTTP/1.0
User-Agent: PHP/5.3.26-dev
Host: 127.0.0.1:12342
Accept: */*
GET /foo/bar4 HTTP/1.0
User-Agent: PHP/5.3.26-dev
Host: 127.0.0.1:12342
Accept: */*
"
-- Test: fail after 2 redirections --
resource(15) of type (stream)
array(2) {
["headers"]=>
array(0) {
}
["readbuf"]=>
resource(16) of type (stream)
}
string(0) ""
string(269) "GET /foo/bar HTTP/1.1
User-Agent: PHP/5.3.26-dev
Host: 127.0.0.1:12342
Accept: */*
GET /foo/bar2 HTTP/1.0
User-Agent: PHP/5.3.26-dev
Host: 127.0.0.1:12342
Accept: */*
GET /foo/bar3 HTTP/1.0
User-Agent: PHP/5.3.26-dev
Host: 127.0.0.1:12342
Accept: */*
"
-- Test: fail at first redirection --
resource(21) of type (stream)
array(2) {
["headers"]=>
array(0) {
}
["readbuf"]=>
resource(22) 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: */*
"
-- Test: fail at first redirection (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: */*
"
-- Test: return at first redirection --
resource(33) of type (stream)
array(2) {
["headers"]=>
array(0) {
}
["readbuf"]=>
resource(34) 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: */*
"
-- Test: return at first redirection (2) --
resource(39) of type (stream)
array(2) {
["headers"]=>
array(0) {
}
["readbuf"]=>
resource(40) 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: */*
"
-- Test: return at second redirection --
resource(45) of type (stream)
array(2) {
["headers"]=>
array(0) {
}
["readbuf"]=>
resource(46) of type (stream)
}
string(0) ""
string(269) "GET /foo/bar HTTP/1.1
User-Agent: PHP/5.3.26-dev
Host: 127.0.0.1:12342
Accept: */*
GET /foo/bar2 HTTP/1.0
User-Agent: PHP/5.3.26-dev
Host: 127.0.0.1:12342
Accept: */*
GET /foo/bar3 HTTP/1.0
User-Agent: PHP/5.3.26-dev
Host: 127.0.0.1:12342
Accept: */*
"
Diff
003+ array(2) {
004+ ["headers"]=>
005+ array(0) {
006+ }
007+ ["readbuf"]=>
008+ resource(10) of type (stream)
009+ }
010+ string(5) "done."
011+ string(359) "GET /foo/bar HTTP/1.1
012+ User-Agent: PHP/5.3.26-dev
013+ Host: 127.0.0.1:12342
014+ Accept: */*
015+
016+ GET /foo/bar2 HTTP/1.0
017+ User-Agent: PHP/5.3.26-dev
003- array(7) {
004- [0]=>
005- string(30) "HTTP/1.0 302 Moved Temporarily"
006- [1]=>
007- string(41) "Location: http://127.0.0.1:12342/foo/bar2"
008- [2]=>
009- string(30) "HTTP/1.0 301 Moved Permanently"
010- [3]=>
011- string(41) "Location: http://127.0.0.1:12342/foo/bar3"
012- [4]=>
013- string(30) "HTTP/1.0 302 Moved Temporarily"
014- [5]=>
015- string(41) "Location: http://127.0.0.1:12342/foo/bar4"
016- [6]=>
017- string(15) "HTTP/1.0 200 OK"
018- }
019- string(5) "done."
020- string(195) "GET /foo/bar HTTP/1.0
019+ Accept: */*
021+ GET /foo/bar3 HTTP/1.0
022+ User-Agent: PHP/5.3.26-dev
023- GET /foo/bar2 HTTP/1.0
024+ Accept: */*
026+ GET /foo/bar4 HTTP/1.0
027+ User-Agent: PHP/5.3.26-dev
026- GET /foo/bar3 HTTP/1.0
029+ Accept: */*
029- GET /foo/bar4 HTTP/1.0
030- Host: 127.0.0.1:12342
031-
033+ resource(15) of type (stream)
034+ array(2) {
035+ ["headers"]=>
036+ array(0) {
037+ }
038+ ["readbuf"]=>
039+ resource(16) of type (stream)
040+ }
041+ string(0) ""
042+ string(269) "GET /foo/bar HTTP/1.1
043+ User-Agent: PHP/5.3.26-dev
034-
035- Warning: fopen(http://127.0.0.1:12342/foo/bar): failed to open stream: Redirection limit reached, aborting in %s
036- bool(false)
037- string(97) "GET /foo/bar HTTP/1.0
045+ Accept: */*
045-
046- Warning: fopen(http://127.0.0.1:12342/foo/bar): failed to open stream: Redirection limit reached, aborting in %s
047- bool(false)
048- string(48) "GET /foo/bar HTTP/1.0
048+ User-Agent: PHP/5.3.26-dev
050+ Accept: */*
052+ GET /foo/bar3 HTTP/1.0
053+ User-Agent: PHP/5.3.26-dev
054+ Host: 127.0.0.1:12342
055+ Accept: */*
056+
053-
054- Warning: fopen(http://127.0.0.1:12342/foo/bar): failed to open stream: Redirection limit reached, aborting in %s
055- bool(false)
056- string(48) "GET /foo/bar HTTP/1.0
059+ resource(21) of type (stream)
060+ array(2) {
061+ ["headers"]=>
062+ array(0) {
063+ }
064+ ["readbuf"]=>
065+ resource(22) of type (stream)
066+ }
067+ string(1) "1"
068+ string(89) "GET /foo/bar HTTP/1.1
069+ User-Agent: PHP/5.3.26-dev
063- [0]=>
064- string(30) "HTTP/1.0 302 Moved Temporarily"
065- [1]=>
066- string(41) "Location: http://127.0.0.1:12342/foo/bar2"
069- string(48) "GET /foo/bar HTTP/1.0
071+ Accept: */*
075+ resource(27) of type (stream)
076+ array(2) {
077+ ["headers"]=>
078+ array(0) {
079+ }
080+ ["readbuf"]=>
081+ resource(28) of type (stream)
082+ }
083+ string(1) "1"
084+ string(89) "GET /foo/bar HTTP/1.1
085+ User-Agent: PHP/5.3.26-dev
076- [0]=>
077- string(30) "HTTP/1.0 302 Moved Temporarily"
078- [1]=>
079- string(41) "Location: http://127.0.0.1:12342/foo/bar2"
082- string(48) "GET /foo/bar HTTP/1.0
087+ Accept: */*
088- array(4) {
089- [0]=>
090- string(30) "HTTP/1.0 302 Moved Temporarily"
091- [1]=>
092- string(41) "Location: http://127.0.0.1:12342/foo/bar2"
093- [2]=>
094- string(30) "HTTP/1.0 301 Moved Permanently"
095- [3]=>
096- string(41) "Location: http://127.0.0.1:12342/foo/bar3"
093+ ["headers"]=>
094+ array(0) {
095+ }
096+ ["readbuf"]=>
097+ resource(34) of type (stream)
099- string(97) "GET /foo/bar HTTP/1.0
100+ string(89) "GET /foo/bar HTTP/1.1
101+ User-Agent: PHP/5.3.26-dev
103+ Accept: */*
109+ ["headers"]=>
110+ array(0) {
111+ }
112+ ["readbuf"]=>
113+ resource(40) of type (stream)
116+ string(89) "GET /foo/bar HTTP/1.1
117+ User-Agent: PHP/5.3.26-dev
119+ Accept: */*
124+ array(2) {
125+ ["headers"]=>
126+ array(0) {
127+ }
128+ ["readbuf"]=>
129+ resource(46) of type (stream)
132+ string(269) "GET /foo/bar HTTP/1.1
133+ User-Agent: PHP/5.3.26-dev
135+ Accept: */*
138+ User-Agent: PHP/5.3.26-dev
140+ Accept: */*
142+ GET /foo/bar3 HTTP/1.0
143+ User-Agent: PHP/5.3.26-dev
144+ Host: 127.0.0.1:12342
145+ Accept: */*
146+
Generated at Sun, 19 May 2013 20:27:25 +0000 (15 hours ago)
|