You are here

function soap_server::parse_http_headers in Salesforce Suite 5

Same name in this branch
  1. 5 includes/nusoap.php \soap_server::parse_http_headers()
  2. 5 includes/nusoap.orig.php \soap_server::parse_http_headers()
Same name and namespace in other branches
  1. 5.2 includes/nusoap.php \soap_server::parse_http_headers()
  2. 5.2 includes/nusoap.orig.php \soap_server::parse_http_headers()

* parses HTTP request headers. * * The following fields are set by this function (when successful) * * headers * request * xml_encoding * SOAPAction * * @access private

2 calls to soap_server::parse_http_headers()
soap_server::parse_request in includes/nusoap.php
* parses a request * * The following fields are set by this function (when successful) * * headers * request * xml_encoding * SOAPAction * request * requestSOAP * methodURI * methodname * methodparams * requestHeaders * document * *…
soap_server::parse_request in includes/nusoap.orig.php
* parses a request * * The following fields are set by this function (when successful) * * headers * request * xml_encoding * SOAPAction * request * requestSOAP * methodURI * methodname * methodparams * requestHeaders * document * *…

File

includes/nusoap.php, line 3318

Class

soap_server
soap_server allows the user to create a SOAP server that is capable of receiving messages and returning responses

Code

function parse_http_headers() {
  global $HTTP_SERVER_VARS;
  $this->request = '';
  $this->SOAPAction = '';
  if (function_exists('getallheaders')) {
    $this
      ->debug("In parse_http_headers, use getallheaders");
    $headers = getallheaders();
    foreach ($headers as $k => $v) {
      $k = strtolower($k);
      $this->headers[$k] = $v;
      $this->request .= "{$k}: {$v}\r\n";
      $this
        ->debug("{$k}: {$v}");
    }

    // get SOAPAction header
    if (isset($this->headers['soapaction'])) {
      $this->SOAPAction = str_replace('"', '', $this->headers['soapaction']);
    }

    // get the character encoding of the incoming request
    if (isset($this->headers['content-type']) && strpos($this->headers['content-type'], '=')) {
      $enc = str_replace('"', '', substr(strstr($this->headers["content-type"], '='), 1));
      if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) {
        $this->xml_encoding = strtoupper($enc);
      }
      else {
        $this->xml_encoding = 'US-ASCII';
      }
    }
    else {

      // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
      $this->xml_encoding = 'ISO-8859-1';
    }
  }
  elseif (isset($_SERVER) && is_array($_SERVER)) {
    $this
      ->debug("In parse_http_headers, use _SERVER");
    foreach ($_SERVER as $k => $v) {
      if (substr($k, 0, 5) == 'HTTP_') {
        $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
        $k = strtolower(substr($k, 5));
      }
      else {
        $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
        $k = strtolower($k);
      }
      if ($k == 'soapaction') {

        // get SOAPAction header
        $k = 'SOAPAction';
        $v = str_replace('"', '', $v);
        $v = str_replace('\\', '', $v);
        $this->SOAPAction = $v;
      }
      else {
        if ($k == 'content-type') {

          // get the character encoding of the incoming request
          if (strpos($v, '=')) {
            $enc = substr(strstr($v, '='), 1);
            $enc = str_replace('"', '', $enc);
            $enc = str_replace('\\', '', $enc);
            if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) {
              $this->xml_encoding = strtoupper($enc);
            }
            else {
              $this->xml_encoding = 'US-ASCII';
            }
          }
          else {

            // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
            $this->xml_encoding = 'ISO-8859-1';
          }
        }
      }
      $this->headers[$k] = $v;
      $this->request .= "{$k}: {$v}\r\n";
      $this
        ->debug("{$k}: {$v}");
    }
  }
  elseif (is_array($HTTP_SERVER_VARS)) {
    $this
      ->debug("In parse_http_headers, use HTTP_SERVER_VARS");
    foreach ($HTTP_SERVER_VARS as $k => $v) {
      if (substr($k, 0, 5) == 'HTTP_') {
        $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
        $k = strtolower(substr($k, 5));
      }
      else {
        $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
        $k = strtolower($k);
      }
      if ($k == 'soapaction') {

        // get SOAPAction header
        $k = 'SOAPAction';
        $v = str_replace('"', '', $v);
        $v = str_replace('\\', '', $v);
        $this->SOAPAction = $v;
      }
      else {
        if ($k == 'content-type') {

          // get the character encoding of the incoming request
          if (strpos($v, '=')) {
            $enc = substr(strstr($v, '='), 1);
            $enc = str_replace('"', '', $enc);
            $enc = str_replace('\\', '', $enc);
            if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) {
              $this->xml_encoding = strtoupper($enc);
            }
            else {
              $this->xml_encoding = 'US-ASCII';
            }
          }
          else {

            // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
            $this->xml_encoding = 'ISO-8859-1';
          }
        }
      }
      $this->headers[$k] = $v;
      $this->request .= "{$k}: {$v}\r\n";
      $this
        ->debug("{$k}: {$v}");
    }
  }
  else {
    $this
      ->debug("In parse_http_headers, HTTP headers not accessible");
    $this
      ->setError("HTTP headers not accessible");
  }
}