92        $this->method = strtoupper(
$method);
 
   94            $this->request = http_build_query(
$params);
 
   99            $this->requestHeaders = explode(
"\n", 
$header);
 
  114        if (function_exists(
'curl_init')) {
 
  117            curl_setopt($ch, CURLOPT_URL, $this->url);
 
  118            if (!empty($this->requestHeaders)) {
 
  119                curl_setopt($ch, CURLOPT_HTTPHEADER, $this->requestHeaders);
 
  121                curl_setopt($ch, CURLOPT_HEADER, 0);
 
  123            if ($this->method === 
'POST') {
 
  124                curl_setopt($ch, CURLOPT_POST, 
true);
 
  125                curl_setopt($ch, CURLOPT_POSTFIELDS, $this->request);
 
  126            } 
else if ($this->method !== 
'GET') {
 
  127                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->method);
 
  128                if (!is_null($this->request)) {
 
  129                    curl_setopt($ch, CURLOPT_POSTFIELDS, $this->request);
 
  132            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 
true);
 
  133            curl_setopt($ch, CURLINFO_HEADER_OUT, 
true);
 
  134            curl_setopt($ch, CURLOPT_HEADER, 
true);
 
  136            #curl_setopt($ch, CURLOPT_SSLVERSION,3); 
  137            $chResp = curl_exec($ch);
 
  141            $this->ok = $chResp !== 
false;
 
  143                $chResp = str_replace(
"\r\n", 
"\n", $chResp);
 
  144                $chRespSplit = explode(
"\n\n", $chResp, 2);
 
  145                if ((count($chRespSplit) > 1) && (substr($chRespSplit[1], 0, 5) === 
'HTTP/')) {
 
  146                    $chRespSplit = explode(
"\n\n", $chRespSplit[1], 2);
 
  148                $this->responseHeaders = $chRespSplit[0];
 
  149                $resp = $chRespSplit[1];
 
  150                $this->status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
  151                $this->ok = $this->status < 400;
 
  153                    $this->
error = curl_error($ch);
 
  156            $this->requestHeaders = str_replace(
"\r\n", 
"\n", curl_getinfo($ch, CURLINFO_HEADER_OUT));
 
  158            $this->response = $resp;
 
  161            $opts = array(
'method' => $this->method,
 
  162                          'content' => $this->request
 
  164            if (!empty($this->requestHeaders)) {
 
  168                $ctx = stream_context_create(array(
'http' => $opts));
 
  169                $fp = @fopen($this->url, 
'rb', 
false, $ctx);
 
  171                    $resp = @stream_get_contents($fp);
 
  172                    $this->ok = $resp !== 
false;
 
  174            } 
catch (\Exception $e) {
 
An exception for terminatinating execution or to throw for unit testing.
Class to represent an HTTP message.
$responseHeaders
Response headers.
__construct($url, $method='GET', $params=null, $header=null)
Class constructor.
$status
Status of response (0 if undetermined).
$ok
True if message was sent successfully.
send()
Send the request to the target URL.
$requestHeaders
Request headers.
error($a_errmsg)
set error message @access public
static getLogger($a_component_id)
Get component logger.