xref: /PHP-7.4/ext/standard/tests/http/bug76342.phpt (revision 175f4f24)
1--TEST--
2Bug #76342 (file_get_contents waits twice specified timeout)
3--INI--
4allow_url_fopen=1
5--SKIPIF--
6<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?>
7--FILE--
8<?php
9require 'server.inc';
10
11$timeout = 0.5;
12$options = [
13  'http' => [
14    'timeout' => $timeout,
15  ],
16];
17
18$ctx = stream_context_create($options);
19
20$pid = http_server_sleep('tcp://127.0.0.1:12342');
21
22$start = microtime(true);
23file_get_contents('http://127.0.0.1:12342/', false, $ctx);
24$diff = microtime(true) - $start;
25if ($diff >= 2 * $timeout) {
26    echo "FAIL: $diff\n";
27}
28
29http_server_kill($pid);
30
31?>
32DONE
33--EXPECTF--
34Warning: file_get_contents(http://127.0.0.1:12342/): failed to open stream: HTTP request failed! in %s on line %d
35DONE
36