Bug #72954 [Opn->Fbk]: file_get_contents: It does not return false at the time of time-out
| From: | ab@php.net | Date: | Sun, 28 Aug 2016 18:43:45 +0000 |
| Subject: | Bug #72954 [Opn->Fbk]: file_get_contents: It does not return false at the time of time-out | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-203633@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72954&edit=1
ID: 72954
Updated by: ab@php.net
Reported by: ne20utri312no at yahoo dot co dot jp
Summary: file_get_contents: It does not return false at the
time of time-out
-Status: Open
+Status: Feedback
Type: Bug
Package: HTTP related
Operating System: Windows
PHP Version: 7.0.10
Block user comment: N
Private report: N
New Comment:
Thanks for the report. With both 5.6 and 7.0 i get with the test script
Execution result: 1.0 sec , string(5) "Hello"
FAILURE
Expected result: 1 sec , bool(false)
This is correct, as "hello" is flushed before sleep. Please provide additional info on how
to reproduce the current behavior you describe. Also, please be sure, there's no any other
process listening on the same port.
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2016-08-28 03:14:25] ne20utri312no at yahoo dot co dot jp
Description:
------------
file_get_contents
It does not return false at the time of time-out
php 7.0.10ã(php 5.6 does not have this bug)
open two shell.
(1)
php -S localhost:8080
(2)
php 2.php
Execution result: 1.0 sec , string(0) ""
FAILURE
Expected result: 1 sec , bool(false)
Test script:
---------------
<?php
// php -S localhost:8080
// php 2.php
ini_set('display_errors', 0);
if (php_sapi_name() == 'cli')
{
$timeout = 1;
ini_set('default_socket_timeout', $timeout);
$st = microtime(TRUE);
$res = file_get_contents('http://localhost:8080/'. basename(__FILE__));
$time = microtime(TRUE) - $st;
ob_start(); var_dump($res); $s = trim(ob_get_contents()); ob_end_clean();
printf("Execution result: %0.1f sec , %s\n", $time, $s);
$success = ($res ===FALSE && round($time)<=$timeout);
echo ($success ? 'Success' : 'FAILURE'). "\n";
printf(" Expected result: %3d sec , bool(false)\n", $timeout);
}
else
{
echo "Hello";
flush();
sleep(1);
echo ' world';
}
Expected result:
----------------
bool(false)
Actual result:
--------------
string(0) ""
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72954&edit=1