Skip to content

Commit 1be39cc

Browse files
committed
Fix Curl HttpClient driver
1 parent 1e24b1c commit 1be39cc

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

‎lib/Github/HttpClient/Curl.php‎

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@ public function doRequest($url, array $parameters = array(), $httpMethod = 'GET'
6666
CURLOPT_TIMEOUT => $options['timeout']
6767
);
6868

69+
$response = $this->doCurlCall($curlOptions);
70+
71+
if (!in_array($response['headers']['http_code'], array(0, 200, 201))) {
72+
throw new Github_HttpClient_Exception(null, (int) $response['headers']['http_code']);
73+
}
74+
75+
if ($response['errorNumber'] != '') {
76+
throw new Github_HttpClient_Exception('error '.$response['errorNumber']);
77+
}
78+
79+
return $response['response'];
80+
}
81+
82+
protected function doCurlCall(array $curlOptions)
83+
{
6984
$curl = curl_init();
7085

7186
curl_setopt_array($curl, $curlOptions);
@@ -77,14 +92,6 @@ public function doRequest($url, array $parameters = array(), $httpMethod = 'GET'
7792

7893
curl_close($curl);
7994

80-
if (!in_array($headers['http_code'], array(0, 200, 201))) {
81-
throw new Github_HttpClient_Exception(null, (int) $headers['http_code']);
82-
}
83-
84-
if ($errorNumber != '') {
85-
throw new Github_HttpClient_Exception('error '.$errorNumber);
86-
}
87-
88-
return $response;
95+
return compact('response', 'headers', 'errorNumber', 'errorMessage');
8996
}
9097
}

0 commit comments

Comments
 (0)