Skip to content

Commit

Permalink
Support precision-based timeouts only when they are available (fixes G…
Browse files Browse the repository at this point in the history
  • 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
Original file line number Diff line number Diff line change
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

3 comments on commit 4c0450f

@markushausammann
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!

@markushausammann
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please tag 7.0.1 soon, thanks a lot!

@dcramer
Copy link
Member Author

@dcramer dcramer commented on 4c0450f Sep 17, 2013 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.