Skip to content

Commit 4467a4f

Browse files
committed
Merge pull request kbsali#50 from GuyFawkes/patch-1
Feature: get last Redmine response code
2 parents b0b3621 + c39f51e commit 4467a4f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/Redmine/Client.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ class Client
5656
* @var array APIs
5757
*/
5858
private $apis = array();
59+
60+
/**
61+
* @var int|null Redmine response code, null if request is not still completed
62+
*/
63+
private $responseCode = null;
5964

6065
/**
6166
* Error strings if json is invalid
@@ -277,6 +282,15 @@ public function setPort($port = null)
277282

278283
return $this;
279284
}
285+
286+
/**
287+
* Returns Redmine response code
288+
* @return int
289+
*/
290+
public function getResponseCode()
291+
{
292+
return $this->responseCode;
293+
}
280294

281295
/**
282296
* Returns the port of the current connection,
@@ -314,6 +328,7 @@ public function getPort($urlPath = null)
314328
*/
315329
private function runRequest($path, $method = 'GET', $data = '')
316330
{
331+
$this->responseCode = null;
317332
$this->getPort($this->url.$path);
318333

319334
$curl = curl_init();
@@ -368,6 +383,7 @@ private function runRequest($path, $method = 'GET', $data = '')
368383
break;
369384
}
370385
$response = curl_exec($curl);
386+
$this->responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
371387

372388
if (curl_errno($curl)) {
373389
$e = new \Exception(curl_error($curl), curl_errno($curl));

0 commit comments

Comments
 (0)