note 94865 modified in function.stream-set-timeout by thiago
| From: | thiago@php.net | Date: | Mon, 30 Nov 2009 12:07:40 +0000 |
| Subject: | note 94865 modified in function.stream-set-timeout by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-163404@lists.php.net to get a copy of this message | ||
I didn't have much luck with the suggestions below (although I likely applied them wrong).
Instead, I used stream_context_create() and set an http option for timeout. I fed that context into
file_get_contents() and voila!
To my desperate friend below: the https transport can also use the http stream context options. I
haven't verified this works as I don't have a slow responding ssl to test on. But if you
are still stressing, give the below a shot (you may need to modify a bit...)
<?php
$timeout = 5*60;
$options = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n",
'timeout' => $timeout
)
);
$context = stream_context_create($options);
$contents = file_get_contents($source, false, $context);
?>
Yes...that is a 5 minute timeout.
--was--
I didn't have much luck with the suggestions below (although I likely applied them wrong).
Instead, I used stream_context_create() and set an http option for timeout. I fed that context into
file_get_contents() and voila!
To my desperate friend below: the https transport can also use the http stream context options. I
haven't verified this works as I don't have a slow responding ssl to test on. But if you
are still stressing, give the below a shot (you may need to modify a bit...)
$timeout = 5*60;
$options = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n",
'timeout' => $timeout
)
);
$context = stream_context_create($options);
$contents = file_get_contents($source, false, $context);
Yes...that is a 5 minute timeout.
http://php.net/manual/en/function.stream-set-timeout.php