Annotation of embedaddon/php/ext/standard/tests/http/bug60570.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Bug #60570 (Stream context leaks when http request fails)
        !             3: --SKIPIF--
        !             4: <?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?>
        !             5: --INI--
        !             6: allow_url_fopen=1
        !             7: allow_url_include=1
        !             8: --FILE--
        !             9: <?php
        !            10: require 'server.inc';
        !            11: 
        !            12: function do_test() {
        !            13: 
        !            14:        $responses = array(
        !            15:                "data://text/plain,HTTP/1.0 404 Not Found\r\n\r\n",
        !            16:                "data://text/plain,HTTP/1.0 404 Not Found\r\n\r\n",
        !            17:                "data://text/plain,HTTP/1.0 404 Not Found\r\n\r\n"
        !            18:        );
        !            19: 
        !            20:        $pid = http_server("tcp://127.0.0.1:12342", $responses, $output);
        !            21: 
        !            22:        $a = $b = null;
        !            23: 
        !            24:        $i = 3;
        !            25:        while ($i--) {
        !            26:                $context = stream_context_create(array('http'=>array('timeout'=>1)));
        !            27:                file_get_contents('http://127.0.0.1:12342/', 0, $context);
        !            28:                unset($context);
        !            29:                
        !            30:                $b = $a;
        !            31:                $a = memory_get_usage();
        !            32:        }
        !            33: 
        !            34:        http_server_kill($pid);
        !            35: 
        !            36:        echo "leak? penultimate iteration: $b, last one: $a\n";
        !            37:        var_dump($a == $b);
        !            38: }
        !            39: 
        !            40: do_test();
        !            41: 
        !            42: --EXPECTF--
        !            43: Warning: file_get_contents(http://127.0.0.1:12342/): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found
        !            44:  in %s on line %d
        !            45: 
        !            46: Warning: file_get_contents(http://127.0.0.1:12342/): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found
        !            47:  in %s on line %d
        !            48: 
        !            49: Warning: file_get_contents(http://127.0.0.1:12342/): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found
        !            50:  in %s on line %d
        !            51: leak? penultimate iteration: %d, last one: %d
        !            52: bool(true)
        !            53: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>