You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jk...@apache.org on 2018/10/03 19:12:35 UTC
[thrift] branch master updated: THRIFT-4645: TCurlClient: include
failure reason in exception
This is an automated email from the ASF dual-hosted git repository.
jking pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git
The following commit(s) were added to refs/heads/master by this push:
new 4a98306 THRIFT-4645: TCurlClient: include failure reason in exception
4a98306 is described below
commit 4a983069a63a6b0be0ae07e6dc4b0b23be44d93a
Author: James Johnston <ja...@thumbtack.com>
AuthorDate: Tue Oct 2 17:30:42 2018 -0700
THRIFT-4645: TCurlClient: include failure reason in exception
When curl_exec fails, more detailed failure information is available
by calling curl_error. Include this error information in the message in
the thrown TTransportException.
Also change the comparison of the return value of curl_exec to
explicitly check for boolean false, so as to distinguish from an empty
response body (per the PHP documentation on this subject).
---
lib/php/lib/Transport/TCurlClient.php | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/php/lib/Transport/TCurlClient.php b/lib/php/lib/Transport/TCurlClient.php
index 2ca4f65..3d4908d 100644
--- a/lib/php/lib/Transport/TCurlClient.php
+++ b/lib/php/lib/Transport/TCurlClient.php
@@ -219,15 +219,19 @@ class TCurlClient extends TTransport
curl_setopt(self::$curlHandle, CURLOPT_URL, $fullUrl);
$this->response_ = curl_exec(self::$curlHandle);
+ $responseError = curl_error(self::$curlHandle);
$code = curl_getinfo(self::$curlHandle, CURLINFO_HTTP_CODE);
// Handle non 200 status code / connect failure
- if (!$this->response_ || $code !== 200) {
+ if ($this->response_ === false || $code !== 200) {
curl_close(self::$curlHandle);
self::$curlHandle = null;
$this->response_ = null;
$error = 'TCurlClient: Could not connect to ' . $fullUrl;
+ if ($responseError) {
+ $error .= ', ' . $responseError;
+ }
if ($code) {
$error .= ', HTTP status code: ' . $code;
}