Skip to content

Commit 2eaf08d

Browse files
committed
fix a bug for failed query
this would previously always set the ret.code to the curl response code, even if the query failed. Maybe we want to switch to that in the future, but for now we return -1 for invalid queries still.
1 parent 194b3aa commit 2eaf08d

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

source/connection.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,11 @@ RestClient::Connection::performCurlRequest(const std::string& uri) {
127127

128128
ret.body = "Failed to query.";
129129
ret.code = -1;
130+
} else {
131+
int64_t http_code = 0;
132+
curl_easy_getinfo(this->curlHandle, CURLINFO_RESPONSE_CODE, &http_code);
133+
ret.code = static_cast<int>(http_code);
130134
}
131-
int64_t http_code = 0;
132-
curl_easy_getinfo(this->curlHandle, CURLINFO_RESPONSE_CODE, &http_code);
133-
ret.code = static_cast<int>(http_code);
134135

135136
// TODO(mrtazz): get metrics from curl handle
136137
// free header list

0 commit comments

Comments
 (0)