Skip to content

Commit b85bf16

Browse files
committed
Curl status code check
1 parent 0cc08cc commit b85bf16

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/CurlRequest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,18 @@ public static function processRequest($ch)
135135
// $output contains the output string
136136
$output = curl_exec($ch);
137137

138-
if(curl_errno($ch)) {
138+
if (curl_errno($ch)) {
139139
throw new Exception\CurlException(curl_errno($ch) . ' : ' . curl_error($ch));
140140
}
141141

142+
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
143+
$httpOK = 200;
144+
$httpCreated = 201;
145+
146+
if ($httpCode != $httpOK && $httpCode != $httpCreated) {
147+
throw new Exception\CurlException("Request failed with HTTP Code $httpCode.");
148+
}
149+
142150
// close curl resource to free up system resources
143151
curl_close($ch);
144152

0 commit comments

Comments
 (0)