Skip to content
This repository was archived by the owner on Apr 8, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/Purl.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ class Purl
*/
private $_errorno = '';

/**
* Last response code
*
* @var type
*/
private $_responseno = null;

/**
* URL to call
*
Expand Down Expand Up @@ -120,6 +127,16 @@ public function setOption($option, $value)
return true;
}

/**
* Get last response number
*
* @return int
*/
public function getResponseNumber()
{
return $this->_responseno;
}

/**
* Get last error number
*
Expand Down Expand Up @@ -266,6 +283,8 @@ protected function _call($query, $headers)
$this->_result = implode($http_response_header, "\r\n") . "\r\n\r\n" . $this->_result;
}

$this->_responseno=explode(' ',$http_response_header[0])[1];

return isset($this->_options[CURLOPT_RETURNTRANSFER]) ? $this->_result : true;
}

Expand Down
1 change: 1 addition & 0 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ function curl_exec(\Purl $ch) {
//////////////// NOT SUPPORTED FUNCTIONS //////////////////////////////////////

function curl_getinfo(\Purl $ch, $opt = 0) {
if ($opt==CURLINFO_HTTP_CODE) { return $ch->getResponseNumber(); }
trigger_error(__FUNCTION__ . PURL_NOT_SUPPORTED_MSG, PURL_ERROR_TYPE);
}

Expand Down