Skip to content

Commit 43bea55

Browse files
author
Ian Barber
committed
Adding stream timeout
Added connect timeout to cURL method as well.
1 parent 1c93b1d commit 43bea55

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/Google/IO/Curl.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ public function setOptions($options)
9999
*/
100100
public function setTimeout($timeout)
101101
{
102+
// Since this timeout is really for putting a bound on the time
103+
// we'll set them both to the same. If you need to specify a longer
104+
// CURLOPT_TIMEOUT, or a tigher CONNECTTIMEOUT, the best thing to
105+
// do is use the setOptions method for the values individually.
106+
$this->options[CURLOPT_CONNECTTIMEOUT] = $timeout;
102107
$this->options[CURLOPT_TIMEOUT] = $timeout;
103108
}
104109
}

src/Google/IO/Stream.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ public function executeRequest(Google_Http_Request $request)
101101
// time situation.
102102
@$fh = fopen($url, 'r', false, $context);
103103

104+
if (isset($this->options[self::TIMEOUT])) {
105+
stream_set_timeout($fh, $this->options[self::TIMEOUT]);
106+
}
107+
104108
$response_data = false;
105109
$respHttpCode = self::UNKNOWN_CODE;
106110
if ($fh) {

0 commit comments

Comments
 (0)