xref: /PHP-8.2/ext/standard/tests/http/bug76342.phpt (revision 95f25837)
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(); ?>
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' => $pid, 'uri' => $uri] = http_server_sleep();
21
22$start = microtime(true);
23file_get_contents($uri, 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://%s:%d): Failed to open stream: HTTP request failed! in %s on line %d
35DONE
36