summaryrefslogtreecommitdiff
path: root/ext/standard/tests/http/bug76342.phpt
blob: ee943ca365299855db90703223933a5e75aa3ef6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
--TEST--
Bug #76342 (file_get_contents waits twice specified timeout)
--INI--
allow_url_fopen=1
--SKIPIF--
<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?>
--FILE--
<?php
require 'server.inc';

$timeout = 0.5;
$options = [
  'http' => [
    'timeout' => $timeout,
  ],
];

$ctx = stream_context_create($options);

$pid = http_server_sleep('tcp://127.0.0.1:12342');

$start = microtime(true);
file_get_contents('http://127.0.0.1:12342/', false, $ctx);
$diff = microtime(true) - $start;
if ($diff >= 2 * $timeout) {
    echo "FAIL: $diff\n";
}

http_server_kill($pid);

?>
DONE
--EXPECTF--
Warning: file_get_contents(http://127.0.0.1:12342/): failed to open stream: HTTP request failed! in %s on line %d
DONE