xref: /PHP-5.4/ext/standard/tests/http/bug69337.phpt (revision 45facd15)
1--TEST--
2Bug #69337 (Stream context leaks when http request fails)
3--SKIPIF--
4<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:22345'); ?>
5--INI--
6allow_url_fopen=1
7allow_url_include=1
8--FILE--
9<?php
10require 'server.inc';
11
12function stream_notification_callback($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max)
13{
14	if($notification_code == STREAM_NOTIFY_REDIRECTED) {
15	  // $http_response_header is now a string, but will be used as an array
16     // by php_stream_url_wrap_http_ex() later on
17       $GLOBALS['http_response_header'] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\0\0\0\0";
18    }
19}
20
21$ctx = stream_context_create();
22stream_context_set_params($ctx, array("notification" => "stream_notification_callback"));
23
24$responses = array(
25	"data://text/plain,HTTP/1.0 302 Found\r\nLocation: http://127.0.0.1:22345/try-again\r\n\r\n",
26	"data://text/plain,HTTP/1.0 404 Not Found\r\n\r\n",
27);
28
29$pid = http_server("tcp://127.0.0.1:22345", $responses, $output);
30
31$f = file_get_contents('http://127.0.0.1:22345/', 0, $ctx);
32
33http_server_kill($pid);
34var_dump($f);
35?>
36==DONE==
37--EXPECTF--
38string(26) "HTTP/1.0 404 Not Found
39
40"
41==DONE==