You are here

function soap_transport_http::sendRequest in Salesforce Suite 5

Same name in this branch
  1. 5 includes/nusoap.php \soap_transport_http::sendRequest()
  2. 5 includes/nusoap.orig.php \soap_transport_http::sendRequest()
Same name and namespace in other branches
  1. 5.2 includes/nusoap.php \soap_transport_http::sendRequest()
  2. 5.2 includes/nusoap.orig.php \soap_transport_http::sendRequest()
2 calls to soap_transport_http::sendRequest()
soap_transport_http::send in includes/nusoap.php
* send the SOAP message via HTTP * *
soap_transport_http::send in includes/nusoap.orig.php
* send the SOAP message via HTTP * *

File

includes/nusoap.php, line 2503

Class

soap_transport_http
transport class for sending/receiving data via HTTP and HTTPS NOTE: PHP must be compiled with the CURL extension for HTTPS support

Code

function sendRequest($data, $cookies = NULL) {

  // build cookie string
  $cookie_str = $this
    ->getCookiesForRequest($cookies, $this->scheme == 'ssl' || $this->scheme == 'https');

  // build payload
  $this
    ->buildPayload($data, $cookie_str);
  if ($this->scheme == 'http' || $this->scheme == 'ssl') {

    // send payload
    if (!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
      $this
        ->setError('couldn\'t write message data to socket');
      $this
        ->debug('couldn\'t write message data to socket');
      return false;
    }
    $this
      ->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
    return true;
  }
  else {
    if ($this->scheme == 'https') {

      // set payload
      // TODO: cURL does say this should only be the verb, and in fact it
      // turns out that the URI and HTTP version are appended to this, which
      // some servers refuse to work with

      //curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, $this->outgoing_payload);
      foreach ($this->outgoing_headers as $k => $v) {
        $curl_headers[] = "{$k}: {$v}";
      }
      if ($cookie_str != '') {
        $curl_headers[] = 'Cookie: ' . $cookie_str;
      }
      curl_setopt($this->ch, CURLOPT_HTTPHEADER, $curl_headers);
      if ($this->request_method == "POST") {
        curl_setopt($this->ch, CURLOPT_POST, 1);
        curl_setopt($this->ch, CURLOPT_POSTFIELDS, $data);
      }
      else {
      }
      $this
        ->debug('set cURL payload');
      return true;
    }
  }
}