Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
Support precision-based timeouts only when they are available (fixes …
Browse files Browse the repository at this point in the history
…GH-76)
  • Loading branch information
dcramer committed Sep 17, 2013
1 parent 4e283ee commit 4c0450f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/Raven/Client.php
Expand Up @@ -489,8 +489,17 @@ private function send_http($url, $data, $headers=array())
curl_setopt($curl, CURLOPT_VERBOSE, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, $this->timeout * 1E3);
curl_setopt($curl, CURLOPT_TIMEOUT_MS, $this->timeout * 1E3);
if (defined('CURLOPT_TIMEOUT_MS')) {
// MS is available in curl >= 7.16.2
$timeout = max(1, ceil(1000 * $this->timeout));
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, $timeout);
curl_setopt($curl, CURLOPT_TIMEOUT_MS, $timeout);
} else {
// fall back to the lower-precision timeout.
$timeout = max(1, ceil($this->timeout));
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
}
$ret = curl_exec($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$success = ($code == 200);
Expand Down

0 comments on commit 4c0450f

Please sign in to comment.