ILIAS  release_8 Revision v8.23
soap_transport_http Class Reference

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

+ Inheritance diagram for soap_transport_http:
+ Collaboration diagram for soap_transport_http:

Public Member Functions

 __construct ($url, $curl_options=null, $use_curl=false)
 constructor More...
 
 setCurlOption ($option, $value)
 sets a cURL option More...
 
 setHeader ($name, $value)
 sets an HTTP header More...
 
 unsetHeader ($name)
 unsets an HTTP header More...
 
 setURL ($url)
 sets the URL to which to connect More...
 
 io_method ()
 gets the I/O method to use More...
 
 connect ($connection_timeout=0, $response_timeout=30)
 establish an HTTP connection More...
 
 send ($data, $timeout=0, $response_timeout=30, $cookies=null)
 sends the SOAP request and gets the SOAP response via HTTP[S] More...
 
 sendHTTPS ($data, $timeout=0, $response_timeout=30, $cookies=null)
 sends the SOAP request and gets the SOAP response via HTTPS using CURL More...
 
 setCredentials ($username, $password, $authtype='basic', $digestRequest=array(), $certRequest=array())
 if authenticating, set user credentials here More...
 
 setSOAPAction ($soapaction)
 set the soapaction value More...
 
 setEncoding ($enc='gzip, deflate')
 use http encoding More...
 
 setProxy ($proxyhost, $proxyport, $proxyusername='', $proxypassword='', $proxyauthtype='basic')
 set proxy info here More...
 
 isSkippableCurlHeader (&$data)
 Test if the given string starts with a header that is to be skipped. More...
 
 decodeChunked ($buffer, $lb)
 decode a string that is encoded w/ "chunked' transfer encoding as defined in RFC2068 19.4.6 More...
 
 buildPayload ($data, $cookie_str='')
 Writes the payload, including HTTP headers, to $this->outgoing_payload. More...
 
 sendRequest ($data, $cookies=null)
 sends the SOAP request via HTTP[S] More...
 
 getResponse ()
 gets the SOAP response via HTTP[S] More...
 
 setContentType ($type, $charset=false)
 sets the content-type for the SOAP message to be sent More...
 
 usePersistentConnection ()
 specifies that an HTTP persistent connection should be used More...
 
 parseCookie ($cookie_str)
 parse an incoming Cookie into it's parts More...
 
 getCookiesForRequest ($cookies, $secure=false)
 sort out cookies for the current request More...
 
- Public Member Functions inherited from nusoap_base
 __construct ()
 constructor More...
 
 getGlobalDebugLevel ()
 gets the global debug level, which applies to future instances More...
 
 setGlobalDebugLevel ($level)
 sets the global debug level, which applies to future instances More...
 
 getDebugLevel ()
 gets the debug level for this instance More...
 
 setDebugLevel ($level)
 sets the debug level for this instance More...
 
 debug ($string)
 adds debug data to the instance debug string with formatting More...
 
 appendDebug ($string)
 adds debug data to the instance debug string without formatting More...
 
 clearDebug ()
 clears the current debug data for this instance More...
 
getDebug ()
 gets the current debug data for this instance More...
 
getDebugAsXMLComment ()
 gets the current debug data for this instance as an XML comment this may change the contents of the debug data More...
 
 expandEntities ($val)
 expands entities, e.g. More...
 
 getError ()
 returns error string if present More...
 
 setError ($str)
 sets error string More...
 
 isArraySimpleOrStruct ($val)
 detect if array is a simple array or a struct (associative array) More...
 
 serialize_val ($val, $name=false, $type=false, $name_ns=false, $type_ns=false, $attributes=false, $use='encoded', $soapval=false)
 serializes PHP values in accordance w/ section 5. More...
 
 serializeEnvelope ($body, $headers=false, $namespaces=array(), $style='rpc', $use='encoded', $encodingStyle='http://schemas.xmlsoap.org/soap/encoding/')
 serializes a message More...
 
 formatDump ($str)
 formats a string to be inserted into an HTML stream More...
 
 contractQname ($qname)
 contracts (changes namespace to prefix) a qualified name More...
 
 expandQname ($qname)
 expands (changes prefix to namespace) a qualified name More...
 
 getLocalPart ($str)
 returns the local part of a prefixed string returns the original string, if not prefixed More...
 
 getPrefix ($str)
 returns the prefix part of a prefixed string returns false, if not prefixed More...
 
 getNamespaceFromPrefix ($prefix)
 pass it a prefix, it returns a namespace More...
 
 getPrefixFromNamespace ($ns)
 returns the prefix for a given namespace (or prefix) or false if no prefixes registered for the given namespace More...
 
 getmicrotime ()
 returns the time in ODBC canonical form with microseconds More...
 
 varDump ($data)
 Returns a string with the output of var_dump. More...
 
 __toString ()
 represents the object as a string More...
 

Data Fields

 $url = ''
 
 $uri = ''
 
 $digest_uri = ''
 
 $scheme = ''
 
 $host = ''
 
 $port = ''
 
 $path = ''
 
 $request_method = 'POST'
 
 $protocol_version = '1.0'
 
 $encoding = ''
 
 $outgoing_headers = array()
 
 $incoming_headers = array()
 
 $incoming_cookies = array()
 
 $outgoing_payload = ''
 
 $incoming_payload = ''
 
 $response_status_line
 
 $useSOAPAction = true
 
 $persistentConnection = false
 
 $ch = false
 
 $ch_options = array()
 
 $use_curl = false
 
 $proxy = null
 
 $username = ''
 
 $password = ''
 
 $authtype = ''
 
 $digestRequest = array()
 
 $certRequest = array()
 
- Data Fields inherited from nusoap_base
 $title = 'NuSOAP'
 
 $version = '0.7.3'
 
 $revision = '$Revision$'
 
 $error_str = ''
 
 $debug_str = ''
 
 $charencoding = true
 
 $debugLevel
 
 $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'
 
 $soap_defencoding = 'UTF-8'
 
 $namespaces
 
 $usedNamespaces = array()
 
 $typemap
 
 $xmlEntities
 

Detailed Description

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

Author
Dietrich Ayala dietr.nosp@m.ich@.nosp@m.ganx4.nosp@m..com
Scott Nichol snich.nosp@m.ol@u.nosp@m.sers..nosp@m.sour.nosp@m.cefor.nosp@m.ge.n.nosp@m.et
Version
$Id$ public

Definition at line 2186 of file nusoap.php.

Constructor & Destructor Documentation

◆ __construct()

soap_transport_http::__construct (   $url,
  $curl_options = null,
  $use_curl = false 
)

constructor

Parameters
string$urlThe URL to which to connect
array$curl_optionsUser-specified cURL options
boolean$use_curlWhether to try to force cURL use public

Definition at line 2231 of file nusoap.php.

References $url, ILIAS\GlobalScreen\Provider\__construct(), nusoap_base\appendDebug(), nusoap_base\debug(), and nusoap_base\varDump().

2232  {
2234  $this->debug("ctor url=$url use_curl=$use_curl curl_options:");
2235  $this->appendDebug($this->varDump($curl_options));
2236  $this->setURL($url);
2237  if (is_array($curl_options)) {
2238  $this->ch_options = $curl_options;
2239  }
2240  $this->use_curl = $use_curl;
2241  preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
2242  // begin-patch php8
2243  $this->setHeader('User-Agent', $this->title . '/' . $this->version . ' (' . ($rev[1] ?? '1.1') . ')');
2244  }
appendDebug($string)
adds debug data to the instance debug string without formatting
Definition: nusoap.php:305
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2267
setURL($url)
sets the URL to which to connect
Definition: nusoap.php:2293
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
varDump($data)
Returns a string with the output of var_dump.
Definition: nusoap.php:909
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ buildPayload()

soap_transport_http::buildPayload (   $data,
  $cookie_str = '' 
)

Writes the payload, including HTTP headers, to $this->outgoing_payload.

Parameters
string$dataHTTP body
string$cookie_strdata for HTTP Cookie header
Returns
void private

Definition at line 2884 of file nusoap.php.

References $data, XapiProxy\$req, $url, and nusoap_base\debug().

2885  {
2886  // Note: for cURL connections, $this->outgoing_payload is ignored,
2887  // as is the Content-Length header, but these are still created as
2888  // debugging guides.
2889 
2890  // add content-length header
2891  $this->setHeader('Content-Length', strlen($data));
2892 
2893  // start building outgoing payload:
2894  if ($this->proxy) {
2895  $uri = $this->url;
2896  } else {
2897  $uri = $this->uri;
2898  }
2899  $req = "$this->request_method $uri HTTP/$this->protocol_version";
2900  $this->debug("HTTP request: $req");
2901  $this->outgoing_payload = "$req\r\n";
2902 
2903  // loop thru headers, serializing
2904  foreach ($this->outgoing_headers as $k => $v) {
2905  $hdr = $k . ': ' . $v;
2906  $this->debug("HTTP header: $hdr");
2907  $this->outgoing_payload .= "$hdr\r\n";
2908  }
2909 
2910  // add any cookies
2911  if ($cookie_str != '') {
2912  $hdr = 'Cookie: ' . $cookie_str;
2913  $this->debug("HTTP header: $hdr");
2914  $this->outgoing_payload .= "$hdr\r\n";
2915  }
2916 
2917  // header/body separator
2918  $this->outgoing_payload .= "\r\n";
2919 
2920  // add data
2921  $this->outgoing_payload .= $data;
2922  }
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2267
catch(\Exception $e) $req
Definition: xapiproxy.php:93
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
+ Here is the call graph for this function:

◆ connect()

soap_transport_http::connect (   $connection_timeout = 0,
  $response_timeout = 30 
)

establish an HTTP connection

Parameters
integer$timeoutset connection timeout in seconds
integer$response_timeoutset response timeout in seconds
Returns
boolean true if connected, false if not private

Definition at line 2357 of file nusoap.php.

References nusoap_base\$error_str, $path, $url, nusoap_base\appendDebug(), nusoap_base\debug(), nusoap_base\setError(), and nusoap_base\varDump().

2358  {
2359  // For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like
2360  // "regular" socket.
2361  // TODO: disabled for now because OpenSSL must be *compiled* in (not just
2362  // loaded), and until PHP5 stream_get_wrappers is not available.
2363  // if ($this->scheme == 'https') {
2364  // if (version_compare(phpversion(), '4.3.0') >= 0) {
2365  // if (extension_loaded('openssl')) {
2366  // $this->scheme = 'ssl';
2367  // $this->debug('Using SSL over OpenSSL');
2368  // }
2369  // }
2370  // }
2371  $this->debug("connect connection_timeout $connection_timeout, response_timeout $response_timeout, scheme $this->scheme, host $this->host, port $this->port");
2372  if ($this->io_method() == 'socket') {
2373  if (!is_array($this->proxy)) {
2374  $host = $this->host;
2375  $port = $this->port;
2376  } else {
2377  $host = $this->proxy['host'];
2378  $port = $this->proxy['port'];
2379  }
2380 
2381  // use persistent connection
2382  if ($this->persistentConnection && isset($this->fp) && is_resource($this->fp)) {
2383  if (!feof($this->fp)) {
2384  $this->debug('Re-use persistent connection');
2385  return true;
2386  }
2387  fclose($this->fp);
2388  $this->debug('Closed persistent connection at EOF');
2389  }
2390 
2391  // munge host if using OpenSSL
2392  if ($this->scheme == 'ssl') {
2393  $host = 'ssl://' . $host;
2394  }
2395  $this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout);
2396 
2397  // open socket
2398  if ($connection_timeout > 0) {
2399  $this->fp = @fsockopen($host, $this->port, $this->errno, $this->error_str, $connection_timeout);
2400  } else {
2401  $this->fp = @fsockopen($host, $this->port, $this->errno, $this->error_str);
2402  }
2403 
2404  // test pointer
2405  if (!$this->fp) {
2406  $msg = 'Couldn\'t open socket connection to server ' . $this->url;
2407  if ($this->errno) {
2408  $msg .= ', Error (' . $this->errno . '): ' . $this->error_str;
2409  } else {
2410  $msg .= ' prior to connect(). This is often a problem looking up the host name.';
2411  }
2412  $this->debug($msg);
2413  $this->setError($msg);
2414  return false;
2415  }
2416 
2417  // set response timeout
2418  $this->debug('set response timeout to ' . $response_timeout);
2419  socket_set_timeout($this->fp, $response_timeout);
2420 
2421  $this->debug('socket connected');
2422  return true;
2423  } elseif ($this->io_method() == 'curl') {
2424  if (!extension_loaded('curl')) {
2425  // $this->setError('cURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS');
2426  $this->setError('The PHP cURL Extension is required for HTTPS or NLTM. You will need to re-build or update your PHP to included cURL.');
2427  return false;
2428  }
2429  // Avoid warnings when PHP does not have these options
2430  if (defined('CURLOPT_CONNECTIONTIMEOUT')) {
2431  $CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT;
2432  } else {
2433  $CURLOPT_CONNECTIONTIMEOUT = 78;
2434  }
2435  if (defined('CURLOPT_HTTPAUTH')) {
2436  $CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH;
2437  } else {
2438  $CURLOPT_HTTPAUTH = 107;
2439  }
2440  if (defined('CURLOPT_PROXYAUTH')) {
2441  $CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH;
2442  } else {
2443  $CURLOPT_PROXYAUTH = 111;
2444  }
2445  if (defined('CURLAUTH_BASIC')) {
2446  $CURLAUTH_BASIC = CURLAUTH_BASIC;
2447  } else {
2448  $CURLAUTH_BASIC = 1;
2449  }
2450  if (defined('CURLAUTH_DIGEST')) {
2451  $CURLAUTH_DIGEST = CURLAUTH_DIGEST;
2452  } else {
2453  $CURLAUTH_DIGEST = 2;
2454  }
2455  if (defined('CURLAUTH_NTLM')) {
2456  $CURLAUTH_NTLM = CURLAUTH_NTLM;
2457  } else {
2458  $CURLAUTH_NTLM = 8;
2459  }
2460 
2461  $this->debug('connect using cURL');
2462  // init CURL
2463  $this->ch = curl_init();
2464  // set url
2465  $hostURL = ($this->port != '') ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$this->host";
2466  // add path
2467  $hostURL .= $this->path;
2468  $this->setCurlOption(CURLOPT_URL, $hostURL);
2469  // follow location headers (re-directs)
2470  if (ini_get('safe_mode') || ini_get('open_basedir')) {
2471  $this->debug('safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION');
2472  $this->debug('safe_mode = ');
2473  $this->appendDebug($this->varDump(ini_get('safe_mode')));
2474  $this->debug('open_basedir = ');
2475  $this->appendDebug($this->varDump(ini_get('open_basedir')));
2476  } else {
2477  $this->setCurlOption(CURLOPT_FOLLOWLOCATION, 1);
2478  }
2479  // ask for headers in the response output
2480  $this->setCurlOption(CURLOPT_HEADER, 1);
2481  // ask for the response output as the return value
2482  $this->setCurlOption(CURLOPT_RETURNTRANSFER, 1);
2483  // encode
2484  // We manage this ourselves through headers and encoding
2485  // if(function_exists('gzuncompress')){
2486  // $this->setCurlOption(CURLOPT_ENCODING, 'deflate');
2487  // }
2488  // persistent connection
2489  if ($this->persistentConnection) {
2490  // I believe the following comment is now bogus, having applied to
2491  // the code when it used CURLOPT_CUSTOMREQUEST to send the request.
2492  // The way we send data, we cannot use persistent connections, since
2493  // there will be some "junk" at the end of our request.
2494  //$this->setCurlOption(CURL_HTTP_VERSION_1_1, true);
2495  $this->persistentConnection = false;
2496  $this->setHeader('Connection', 'close');
2497  }
2498  // set timeouts
2499  if ($connection_timeout != 0) {
2500  $this->setCurlOption($CURLOPT_CONNECTIONTIMEOUT, $connection_timeout);
2501  }
2502  if ($response_timeout != 0) {
2503  $this->setCurlOption(CURLOPT_TIMEOUT, $response_timeout);
2504  }
2505 
2506  if ($this->scheme == 'https') {
2507  $this->debug('set cURL SSL verify options');
2508  // recent versions of cURL turn on peer/host checking by default,
2509  // while PHP binaries are not compiled with a default location for the
2510  // CA cert bundle, so disable peer/host checking.
2511  //$this->setCurlOption(CURLOPT_CAINFO, 'f:\php-4.3.2-win32\extensions\curl-ca-bundle.crt');
2512  $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
2513  $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0);
2514 
2515  // support client certificates (thanks Tobias Boes, Doug Anarino, Eryan Ariobowo)
2516  if ($this->authtype == 'certificate') {
2517  $this->debug('set cURL certificate options');
2518  if (isset($this->certRequest['cainfofile'])) {
2519  $this->setCurlOption(CURLOPT_CAINFO, $this->certRequest['cainfofile']);
2520  }
2521  if (isset($this->certRequest['verifypeer'])) {
2522  $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, $this->certRequest['verifypeer']);
2523  } else {
2524  $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 1);
2525  }
2526  if (isset($this->certRequest['verifyhost'])) {
2527  $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, $this->certRequest['verifyhost']);
2528  } else {
2529  $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1);
2530  }
2531  if (isset($this->certRequest['sslcertfile'])) {
2532  $this->setCurlOption(CURLOPT_SSLCERT, $this->certRequest['sslcertfile']);
2533  }
2534  if (isset($this->certRequest['sslkeyfile'])) {
2535  $this->setCurlOption(CURLOPT_SSLKEY, $this->certRequest['sslkeyfile']);
2536  }
2537  if (isset($this->certRequest['passphrase'])) {
2538  $this->setCurlOption(CURLOPT_SSLKEYPASSWD, $this->certRequest['passphrase']);
2539  }
2540  if (isset($this->certRequest['certpassword'])) {
2541  $this->setCurlOption(CURLOPT_SSLCERTPASSWD, $this->certRequest['certpassword']);
2542  }
2543  }
2544  }
2545  if ($this->authtype && ($this->authtype != 'certificate')) {
2546  if ($this->username) {
2547  $this->debug('set cURL username/password');
2548  $this->setCurlOption(CURLOPT_USERPWD, "$this->username:$this->password");
2549  }
2550  if ($this->authtype == 'basic') {
2551  $this->debug('set cURL for Basic authentication');
2552  $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_BASIC);
2553  }
2554  if ($this->authtype == 'digest') {
2555  $this->debug('set cURL for digest authentication');
2556  $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_DIGEST);
2557  }
2558  if ($this->authtype == 'ntlm') {
2559  $this->debug('set cURL for NTLM authentication');
2560  $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_NTLM);
2561  }
2562  }
2563  if (is_array($this->proxy)) {
2564  $this->debug('set cURL proxy options');
2565  if ($this->proxy['port'] != '') {
2566  $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host'] . ':' . $this->proxy['port']);
2567  } else {
2568  $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host']);
2569  }
2570  if ($this->proxy['username'] || $this->proxy['password']) {
2571  $this->debug('set cURL proxy authentication options');
2572  $this->setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy['username'] . ':' . $this->proxy['password']);
2573  if ($this->proxy['authtype'] == 'basic') {
2574  $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_BASIC);
2575  }
2576  if ($this->proxy['authtype'] == 'ntlm') {
2577  $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_NTLM);
2578  }
2579  }
2580  }
2581  $this->debug('cURL connection set up');
2582  return true;
2583  } else {
2584  $this->setError('Unknown scheme ' . $this->scheme);
2585  $this->debug('Unknown scheme ' . $this->scheme);
2586  return false;
2587  }
2588  }
appendDebug($string)
adds debug data to the instance debug string without formatting
Definition: nusoap.php:305
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2267
setError($str)
sets error string
Definition: nusoap.php:395
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
setCurlOption($option, $value)
sets a cURL option
Definition: nusoap.php:2253
varDump($data)
Returns a string with the output of var_dump.
Definition: nusoap.php:909
io_method()
gets the I/O method to use
Definition: nusoap.php:2338
+ Here is the call graph for this function:

◆ decodeChunked()

soap_transport_http::decodeChunked (   $buffer,
  $lb 
)

decode a string that is encoded w/ "chunked' transfer encoding as defined in RFC2068 19.4.6

Parameters
string$buffer
string$lb
Returns
string public
Deprecated:

Definition at line 2826 of file nusoap.php.

References nusoap_base\debug().

2827  {
2828  // length := 0
2829  $length = 0;
2830  $new = '';
2831 
2832  // read chunk-size, chunk-extension (if any) and CRLF
2833  // get the position of the linebreak
2834  $chunkend = strpos($buffer, $lb);
2835  if ($chunkend == false) {
2836  $this->debug('no linebreak found in decodeChunked');
2837  return $new;
2838  }
2839  $temp = substr($buffer, 0, $chunkend);
2840  $chunk_size = hexdec(trim($temp));
2841  $chunkstart = $chunkend + strlen($lb);
2842  // while (chunk-size > 0) {
2843  while ($chunk_size > 0) {
2844  $this->debug("chunkstart: $chunkstart chunk_size: $chunk_size");
2845  $chunkend = strpos($buffer, $lb, $chunkstart + $chunk_size);
2846 
2847  // Just in case we got a broken connection
2848  if ($chunkend == false) {
2849  $chunk = substr($buffer, $chunkstart);
2850  // append chunk-data to entity-body
2851  $new .= $chunk;
2852  $length += strlen($chunk);
2853  break;
2854  }
2855 
2856  // read chunk-data and CRLF
2857  $chunk = substr($buffer, $chunkstart, $chunkend-$chunkstart);
2858  // append chunk-data to entity-body
2859  $new .= $chunk;
2860  // length := length + chunk-size
2861  $length += strlen($chunk);
2862  // read chunk-size and CRLF
2863  $chunkstart = $chunkend + strlen($lb);
2864 
2865  $chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb);
2866  if ($chunkend == false) {
2867  break; //Just in case we got a broken connection
2868  }
2869  $temp = substr($buffer, $chunkstart, $chunkend-$chunkstart);
2870  $chunk_size = hexdec(trim($temp));
2871  $chunkstart = $chunkend;
2872  }
2873  return $new;
2874  }
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
+ Here is the call graph for this function:

◆ getCookiesForRequest()

soap_transport_http::getCookiesForRequest (   $cookies,
  $secure = false 
)

sort out cookies for the current request

Parameters
array$cookiesarray with all cookies
boolean$secureis the send-content secure or not?
Returns
string for Cookie-HTTP-Header private

Definition at line 3467 of file nusoap.php.

References $path, and nusoap_base\debug().

3468  {
3469  $cookie_str = '';
3470  if ((! is_null($cookies)) && (is_array($cookies))) {
3471  foreach ($cookies as $cookie) {
3472  if (! is_array($cookie)) {
3473  continue;
3474  }
3475  $this->debug("check cookie for validity: " . $cookie['name'] . '=' . $cookie['value']);
3476  if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
3477  if (strtotime($cookie['expires']) <= time()) {
3478  $this->debug('cookie has expired');
3479  continue;
3480  }
3481  }
3482  if ((isset($cookie['domain'])) && (! empty($cookie['domain']))) {
3483  $domain = preg_quote($cookie['domain']);
3484  if (! preg_match("'.*$domain$'i", $this->host)) {
3485  $this->debug('cookie has different domain');
3486  continue;
3487  }
3488  }
3489  if ((isset($cookie['path'])) && (! empty($cookie['path']))) {
3490  $path = preg_quote($cookie['path']);
3491  if (! preg_match("'^$path.*'i", $this->path)) {
3492  $this->debug('cookie is for a different path');
3493  continue;
3494  }
3495  }
3496  if ((! $secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
3497  $this->debug('cookie is secure, transport is not');
3498  continue;
3499  }
3500  $cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; ';
3501  $this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
3502  }
3503  }
3504  return $cookie_str;
3505  }
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
+ Here is the call graph for this function:

◆ getResponse()

soap_transport_http::getResponse ( )

gets the SOAP response via HTTP[S]

Returns
string the response (also sets member variables like incoming_payload) private

Definition at line 2990 of file nusoap.php.

References $data, nusoap_base\debug(), and nusoap_base\setError().

2991  {
2992  $this->incoming_payload = '';
2993 
2994  if ($this->io_method() == 'socket') {
2995  // loop until headers have been retrieved
2996  $data = '';
2997  while (!isset($lb)) {
2998 
2999  // We might EOF during header read.
3000  if (feof($this->fp)) {
3001  $this->incoming_payload = $data;
3002  $this->debug('found no headers before EOF after length ' . strlen($data));
3003  $this->debug("received before EOF:\n" . $data);
3004  $this->setError('server failed to send headers');
3005  return false;
3006  }
3007 
3008  $tmp = fgets($this->fp, 256);
3009  $tmplen = strlen($tmp);
3010  $this->debug("read line of $tmplen bytes: " . trim($tmp));
3011 
3012  if ($tmplen == 0) {
3013  $this->incoming_payload = $data;
3014  $this->debug('socket read of headers timed out after length ' . strlen($data));
3015  $this->debug("read before timeout: " . $data);
3016  $this->setError('socket read of headers timed out');
3017  return false;
3018  }
3019 
3020  $data .= $tmp;
3021  $pos = strpos($data, "\r\n\r\n");
3022  if ($pos > 1) {
3023  $lb = "\r\n";
3024  } else {
3025  $pos = strpos($data, "\n\n");
3026  if ($pos > 1) {
3027  $lb = "\n";
3028  }
3029  }
3030  // remove 100 headers
3031  if (isset($lb) && preg_match('/^HTTP\/1.1 100/', $data)) {
3032  unset($lb);
3033  $data = '';
3034  }//
3035  }
3036  // store header data
3037  $this->incoming_payload .= $data;
3038  $this->debug('found end of headers after length ' . strlen($data));
3039  // process headers
3040  $header_data = trim(substr($data, 0, $pos));
3041  $header_array = explode($lb, $header_data);
3042  $this->incoming_headers = array();
3043  $this->incoming_cookies = array();
3044  foreach ($header_array as $header_line) {
3045  $arr = explode(':', $header_line, 2);
3046  if (count($arr) > 1) {
3047  $header_name = strtolower(trim($arr[0]));
3048  $this->incoming_headers[$header_name] = trim($arr[1]);
3049  if ($header_name == 'set-cookie') {
3050  // TODO: allow multiple cookies from parseCookie
3051  $cookie = $this->parseCookie(trim($arr[1]));
3052  if ($cookie) {
3053  $this->incoming_cookies[] = $cookie;
3054  $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
3055  } else {
3056  $this->debug('did not find cookie in ' . trim($arr[1]));
3057  }
3058  }
3059  } elseif (isset($header_name)) {
3060  // append continuation line to previous header
3061  $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
3062  }
3063  }
3064 
3065  // loop until msg has been received
3066  if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') {
3067  $content_length = 2147483647; // ignore any content-length header
3068  $chunked = true;
3069  $this->debug("want to read chunked content");
3070  } elseif (isset($this->incoming_headers['content-length'])) {
3071  $content_length = $this->incoming_headers['content-length'];
3072  $chunked = false;
3073  $this->debug("want to read content of length $content_length");
3074  } else {
3075  $content_length = 2147483647;
3076  $chunked = false;
3077  $this->debug("want to read content to EOF");
3078  }
3079  $data = '';
3080  do {
3081  if ($chunked) {
3082  $tmp = fgets($this->fp, 256);
3083  $tmplen = strlen($tmp);
3084  $this->debug("read chunk line of $tmplen bytes");
3085  if ($tmplen == 0) {
3086  $this->incoming_payload = $data;
3087  $this->debug('socket read of chunk length timed out after length ' . strlen($data));
3088  $this->debug("read before timeout:\n" . $data);
3089  $this->setError('socket read of chunk length timed out');
3090  return false;
3091  }
3092  $content_length = hexdec(trim($tmp));
3093  $this->debug("chunk length $content_length");
3094  }
3095  $strlen = 0;
3096  while (($strlen < $content_length) && (!feof($this->fp))) {
3097  $readlen = min(8192, $content_length - $strlen);
3098  $tmp = fread($this->fp, $readlen);
3099  $tmplen = strlen($tmp);
3100  $this->debug("read buffer of $tmplen bytes");
3101  if (($tmplen == 0) && (!feof($this->fp))) {
3102  $this->incoming_payload = $data;
3103  $this->debug('socket read of body timed out after length ' . strlen($data));
3104  $this->debug("read before timeout:\n" . $data);
3105  $this->setError('socket read of body timed out');
3106  return false;
3107  }
3108  $strlen += $tmplen;
3109  $data .= $tmp;
3110  }
3111  if ($chunked && ($content_length > 0)) {
3112  $tmp = fgets($this->fp, 256);
3113  $tmplen = strlen($tmp);
3114  $this->debug("read chunk terminator of $tmplen bytes");
3115  if ($tmplen == 0) {
3116  $this->incoming_payload = $data;
3117  $this->debug('socket read of chunk terminator timed out after length ' . strlen($data));
3118  $this->debug("read before timeout:\n" . $data);
3119  $this->setError('socket read of chunk terminator timed out');
3120  return false;
3121  }
3122  }
3123  } while ($chunked && ($content_length > 0) && (!feof($this->fp)));
3124  if (feof($this->fp)) {
3125  $this->debug('read to EOF');
3126  }
3127  $this->debug('read body of length ' . strlen($data));
3128  $this->incoming_payload .= $data;
3129  $this->debug('received a total of ' . strlen($this->incoming_payload) . ' bytes of data from server');
3130 
3131  // close filepointer
3132  if (
3133  (isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') ||
3134  (! $this->persistentConnection) || feof($this->fp)) {
3135  fclose($this->fp);
3136  $this->fp = false;
3137  $this->debug('closed socket');
3138  }
3139 
3140  // connection was closed unexpectedly
3141  if ($this->incoming_payload == '') {
3142  $this->setError('no response from server');
3143  return false;
3144  }
3145 
3146  // decode transfer-encoding
3147 // if(isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked'){
3148 // if(!$data = $this->decodeChunked($data, $lb)){
3149 // $this->setError('Decoding of chunked data failed');
3150 // return false;
3151 // }
3152  //print "<pre>\nde-chunked:\n---------------\n$data\n\n---------------\n</pre>";
3153  // set decoded payload
3154 // $this->incoming_payload = $header_data.$lb.$lb.$data;
3155 // }
3156  } elseif ($this->io_method() == 'curl') {
3157  // send and receive
3158  $this->debug('send and receive with cURL');
3159  $this->incoming_payload = curl_exec($this->ch);
3161 
3162  $cErr = curl_error($this->ch);
3163  if ($cErr != '') {
3164  $err = 'cURL ERROR: ' . curl_errno($this->ch) . ': ' . $cErr . '<br>';
3165  // TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE
3166  foreach (curl_getinfo($this->ch) as $k => $v) {
3167  $err .= "$k: $v<br>";
3168  }
3169  $this->debug($err);
3170  $this->setError($err);
3171  curl_close($this->ch);
3172  return false;
3173  } else {
3174  //echo '<pre>';
3175  //var_dump(curl_getinfo($this->ch));
3176  //echo '</pre>';
3177  }
3178  // close curl
3179  $this->debug('No cURL error, closing cURL');
3180  curl_close($this->ch);
3181 
3182  // try removing skippable headers
3183  $savedata = $data;
3184  while ($this->isSkippableCurlHeader($data)) {
3185  $this->debug("Found HTTP header to skip");
3186  if ($pos = strpos($data, "\r\n\r\n")) {
3187  $data = ltrim(substr($data, $pos));
3188  } elseif ($pos = strpos($data, "\n\n")) {
3189  $data = ltrim(substr($data, $pos));
3190  }
3191  }
3192 
3193  if ($data == '') {
3194  // have nothing left; just remove 100 header(s)
3195  $data = $savedata;
3196  while (preg_match('/^HTTP\/1.1 100/', $data)) {
3197  if ($pos = strpos($data, "\r\n\r\n")) {
3198  $data = ltrim(substr($data, $pos));
3199  } elseif ($pos = strpos($data, "\n\n")) {
3200  $data = ltrim(substr($data, $pos));
3201  }
3202  }
3203  }
3204 
3205  // separate content from HTTP headers
3206  if ($pos = strpos($data, "\r\n\r\n")) {
3207  $lb = "\r\n";
3208  } elseif ($pos = strpos($data, "\n\n")) {
3209  $lb = "\n";
3210  } else {
3211  $this->debug('no proper separation of headers and document');
3212  $this->setError('no proper separation of headers and document');
3213  return false;
3214  }
3215  $header_data = trim(substr($data, 0, $pos));
3216  $header_array = explode($lb, $header_data);
3217  $data = ltrim(substr($data, $pos));
3218  $this->debug('found proper separation of headers and document');
3219  $this->debug('cleaned data, stringlen: ' . strlen($data));
3220  // clean headers
3221  foreach ($header_array as $header_line) {
3222  $arr = explode(':', $header_line, 2);
3223  if (count($arr) > 1) {
3224  $header_name = strtolower(trim($arr[0]));
3225  $this->incoming_headers[$header_name] = trim($arr[1]);
3226  if ($header_name == 'set-cookie') {
3227  // TODO: allow multiple cookies from parseCookie
3228  $cookie = $this->parseCookie(trim($arr[1]));
3229  if ($cookie) {
3230  $this->incoming_cookies[] = $cookie;
3231  $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
3232  } else {
3233  $this->debug('did not find cookie in ' . trim($arr[1]));
3234  }
3235  }
3236  } elseif (isset($header_name)) {
3237  // append continuation line to previous header
3238  $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
3239  }
3240  }
3241  }
3242 
3243  $this->response_status_line = $header_array[0];
3244  $arr = explode(' ', $this->response_status_line, 3);
3245  $http_version = $arr[0];
3246  $http_status = intval($arr[1]);
3247  $http_reason = count($arr) > 2 ? $arr[2] : '';
3248 
3249  // see if we need to resend the request with http digest authentication
3250  if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
3251  $this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']);
3252  $this->setURL($this->incoming_headers['location']);
3253  $this->tryagain = true;
3254  return false;
3255  }
3256 
3257  // see if we need to resend the request with http digest authentication
3258  if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
3259  $this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']);
3260  if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
3261  $this->debug('Server wants digest authentication');
3262  // remove "Digest " from our elements
3263  $digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']);
3264 
3265  // parse elements into array
3266  $digestElements = explode(',', $digestString);
3267  foreach ($digestElements as $val) {
3268  $tempElement = explode('=', trim($val), 2);
3269  $digestRequest[$tempElement[0]] = str_replace("\"", '', $tempElement[1]);
3270  }
3271 
3272  // should have (at least) qop, realm, nonce
3273  if (isset($digestRequest['nonce'])) {
3274  $this->setCredentials($this->username, $this->password, 'digest', $digestRequest);
3275  $this->tryagain = true;
3276  return false;
3277  }
3278  }
3279  $this->debug('HTTP authentication failed');
3280  $this->setError('HTTP authentication failed');
3281  return false;
3282  }
3283 
3284  if (
3285  ($http_status >= 300 && $http_status <= 307) ||
3286  ($http_status >= 400 && $http_status <= 417) ||
3287  ($http_status >= 501 && $http_status <= 505)
3288  ) {
3289  $this->setError("Unsupported HTTP response status $http_status $http_reason (soapclient->response has contents of the response)");
3290  return false;
3291  }
3292 
3293  // decode content-encoding
3294  if (isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != '') {
3295  if (strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip') {
3296  // if decoding works, use it. else assume data wasn't gzencoded
3297  if (function_exists('gzinflate')) {
3298  //$timer->setMarker('starting decoding of gzip/deflated content');
3299  // IIS 5 requires gzinflate instead of gzuncompress (similar to IE 5 and gzdeflate v. gzcompress)
3300  // this means there are no Zlib headers, although there should be
3301  $this->debug('The gzinflate function exists');
3302  $datalen = strlen($data);
3303  if ($this->incoming_headers['content-encoding'] == 'deflate') {
3304  if ($degzdata = @gzinflate($data)) {
3305  $data = $degzdata;
3306  $this->debug('The payload has been inflated to ' . strlen($data) . ' bytes');
3307  if (strlen($data) < $datalen) {
3308  // test for the case that the payload has been compressed twice
3309  $this->debug('The inflated payload is smaller than the gzipped one; try again');
3310  if ($degzdata = @gzinflate($data)) {
3311  $data = $degzdata;
3312  $this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes');
3313  }
3314  }
3315  } else {
3316  $this->debug('Error using gzinflate to inflate the payload');
3317  $this->setError('Error using gzinflate to inflate the payload');
3318  }
3319  } elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
3320  if ($degzdata = @gzinflate(substr($data, 10))) { // do our best
3321  $data = $degzdata;
3322  $this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes');
3323  if (strlen($data) < $datalen) {
3324  // test for the case that the payload has been compressed twice
3325  $this->debug('The un-gzipped payload is smaller than the gzipped one; try again');
3326  if ($degzdata = @gzinflate(substr($data, 10))) {
3327  $data = $degzdata;
3328  $this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes');
3329  }
3330  }
3331  } else {
3332  $this->debug('Error using gzinflate to un-gzip the payload');
3333  $this->setError('Error using gzinflate to un-gzip the payload');
3334  }
3335  }
3336  //$timer->setMarker('finished decoding of gzip/deflated content');
3337  //print "<xmp>\nde-inflated:\n---------------\n$data\n-------------\n</xmp>";
3338  // set decoded payload
3339  $this->incoming_payload = $header_data . $lb . $lb . $data;
3340  } else {
3341  $this->debug('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
3342  $this->setError('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
3343  }
3344  } else {
3345  $this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
3346  $this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
3347  }
3348  } else {
3349  $this->debug('No Content-Encoding header');
3350  }
3351 
3352  if (strlen($data) == 0) {
3353  $this->debug('no data after headers!');
3354  $this->setError('no data present after HTTP headers');
3355  return false;
3356  }
3357 
3358  return $data;
3359  }
setCredentials($username, $password, $authtype='basic', $digestRequest=array(), $certRequest=array())
if authenticating, set user credentials here
Definition: nusoap.php:2656
setError($str)
sets error string
Definition: nusoap.php:395
setURL($url)
sets the URL to which to connect
Definition: nusoap.php:2293
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
isSkippableCurlHeader(&$data)
Test if the given string starts with a header that is to be skipped.
Definition: nusoap.php:2796
parseCookie($cookie_str)
parse an incoming Cookie into it&#39;s parts
Definition: nusoap.php:3400
io_method()
gets the I/O method to use
Definition: nusoap.php:2338
+ Here is the call graph for this function:

◆ io_method()

soap_transport_http::io_method ( )

gets the I/O method to use

Returns
string I/O method to use (socket|curl|unknown) private

Definition at line 2338 of file nusoap.php.

2339  {
2340  if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm')) {
2341  return 'curl';
2342  }
2343  if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm')) {
2344  return 'socket';
2345  }
2346  return 'unknown';
2347  }

◆ isSkippableCurlHeader()

soap_transport_http::isSkippableCurlHeader ( $data)

Test if the given string starts with a header that is to be skipped.

Skippable headers result from chunked transfer and proxy requests.

Parameters
string$dataThe string to check.
Returns
boolean Whether a skippable header was found. private

Definition at line 2796 of file nusoap.php.

References $data.

2797  {
2798  $skipHeaders = array( 'HTTP/1.1 100',
2799  'HTTP/1.0 301',
2800  'HTTP/1.1 301',
2801  'HTTP/1.0 302',
2802  'HTTP/1.1 302',
2803  'HTTP/1.0 401',
2804  'HTTP/1.1 401',
2805  'HTTP/1.0 200 Connection established');
2806  foreach ($skipHeaders as $hd) {
2807  $prefix = substr($data, 0, strlen($hd));
2808  if ($prefix == $hd) {
2809  return true;
2810  }
2811  }
2812 
2813  return false;
2814  }

◆ parseCookie()

soap_transport_http::parseCookie (   $cookie_str)

parse an incoming Cookie into it's parts

Parameters
string$cookie_strcontent of cookie
Returns
array with data of that cookie private

Definition at line 3400 of file nusoap.php.

References $data, $name, and $path.

3401  {
3402  $cookie_str = str_replace('; ', ';', $cookie_str) . ';';
3403  // begin-patch php8
3404  //$data = split(';', $cookie_str);
3405  $data = explode(';', $cookie_str);
3406  $value_str = $data[0];
3407 
3408  $cookie_param = 'domain=';
3409  $start = strpos($cookie_str, $cookie_param);
3410  if ($start > 0) {
3411  $domain = substr($cookie_str, $start + strlen($cookie_param));
3412  $domain = substr($domain, 0, strpos($domain, ';'));
3413  } else {
3414  $domain = '';
3415  }
3416 
3417  $cookie_param = 'expires=';
3418  $start = strpos($cookie_str, $cookie_param);
3419  if ($start > 0) {
3420  $expires = substr($cookie_str, $start + strlen($cookie_param));
3421  $expires = substr($expires, 0, strpos($expires, ';'));
3422  } else {
3423  $expires = '';
3424  }
3425 
3426  $cookie_param = 'path=';
3427  $start = strpos($cookie_str, $cookie_param);
3428  if ($start > 0) {
3429  $path = substr($cookie_str, $start + strlen($cookie_param));
3430  $path = substr($path, 0, strpos($path, ';'));
3431  } else {
3432  $path = '/';
3433  }
3434 
3435  $cookie_param = ';secure;';
3436  if (strpos($cookie_str, $cookie_param) !== false) {
3437  $secure = true;
3438  } else {
3439  $secure = false;
3440  }
3441 
3442  $sep_pos = strpos($value_str, '=');
3443 
3444  if ($sep_pos) {
3445  $name = substr($value_str, 0, $sep_pos);
3446  $value = substr($value_str, $sep_pos + 1);
3447  $cookie= array( 'name' => $name,
3448  'value' => $value,
3449  'domain' => $domain,
3450  'path' => $path,
3451  'expires' => $expires,
3452  'secure' => $secure
3453  );
3454  return $cookie;
3455  }
3456  return false;
3457  }
if($format !==null) $name
Definition: metadata.php:247

◆ send()

soap_transport_http::send (   $data,
  $timeout = 0,
  $response_timeout = 30,
  $cookies = null 
)

sends the SOAP request and gets the SOAP response via HTTP[S]

Parameters
string$datamessage data
integer$timeoutset connection timeout in seconds
integer$response_timeoutset response timeout in seconds
array$cookiescookies to send
Returns
string data public

Definition at line 2600 of file nusoap.php.

References $data, nusoap_base\debug(), and nusoap_base\setError().

2601  {
2602  $this->debug('entered send() with data of length: ' . strlen($data));
2603 
2604  $this->tryagain = true;
2605  $tries = 0;
2606  while ($this->tryagain) {
2607  $this->tryagain = false;
2608  if ($tries++ < 2) {
2609  // make connnection
2610  if (!$this->connect($timeout, $response_timeout)) {
2611  return false;
2612  }
2613 
2614  // send request
2615  if (!$this->sendRequest($data, $cookies)) {
2616  return false;
2617  }
2618 
2619  // get response
2620  $respdata = $this->getResponse();
2621  } else {
2622  $this->setError("Too many tries to get an OK response ($this->response_status_line)");
2623  }
2624  }
2625  $this->debug('end of send()');
2626  return $respdata;
2627  }
connect($connection_timeout=0, $response_timeout=30)
establish an HTTP connection
Definition: nusoap.php:2357
setError($str)
sets error string
Definition: nusoap.php:395
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
sendRequest($data, $cookies=null)
sends the SOAP request via HTTP[S]
Definition: nusoap.php:2932
getResponse()
gets the SOAP response via HTTP[S]
Definition: nusoap.php:2990
+ Here is the call graph for this function:

◆ sendHTTPS()

soap_transport_http::sendHTTPS (   $data,
  $timeout = 0,
  $response_timeout = 30,
  $cookies = null 
)

sends the SOAP request and gets the SOAP response via HTTPS using CURL

Parameters
string$datamessage data
integer$timeoutset connection timeout in seconds
integer$response_timeoutset response timeout in seconds
array$cookiescookies to send
Returns
string data public
Deprecated:

Definition at line 2641 of file nusoap.php.

References $data, and send().

2642  {
2643  return $this->send($data, $timeout, $response_timeout, $cookies);
2644  }
send($data, $timeout=0, $response_timeout=30, $cookies=null)
sends the SOAP request and gets the SOAP response via HTTP[S]
Definition: nusoap.php:2600
+ Here is the call graph for this function:

◆ sendRequest()

soap_transport_http::sendRequest (   $data,
  $cookies = null 
)

sends the SOAP request via HTTP[S]

Parameters
string$datamessage data
array$cookiescookies to send
Returns
boolean true if OK, false if problem private

Definition at line 2932 of file nusoap.php.

References $data, ILIAS\LTI\ToolProvider\$key, nusoap_base\debug(), and nusoap_base\setError().

2933  {
2934  // build cookie string
2935  $cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https')));
2936 
2937  // build payload
2938  $this->buildPayload($data, $cookie_str);
2939 
2940  if ($this->io_method() == 'socket') {
2941  // send payload
2942  if (!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
2943  $this->setError('couldn\'t write message data to socket');
2944  $this->debug('couldn\'t write message data to socket');
2945  return false;
2946  }
2947  $this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
2948  return true;
2949  } elseif ($this->io_method() == 'curl') {
2950  // set payload
2951  // cURL does say this should only be the verb, and in fact it
2952  // turns out that the URI and HTTP version are appended to this, which
2953  // some servers refuse to work with (so we no longer use this method!)
2954  //$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload);
2955  $curl_headers = array();
2956  foreach ($this->outgoing_headers as $k => $v) {
2957  if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') {
2958  $this->debug("Skip cURL header $k: $v");
2959  } else {
2960  $curl_headers[] = "$k: $v";
2961  }
2962  }
2963  if ($cookie_str != '') {
2964  $curl_headers[] = 'Cookie: ' . $cookie_str;
2965  }
2966  $this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers);
2967  $this->debug('set cURL HTTP headers');
2968  if ($this->request_method == "POST") {
2969  $this->setCurlOption(CURLOPT_POST, 1);
2970  $this->setCurlOption(CURLOPT_POSTFIELDS, $data);
2971  $this->debug('set cURL POST data');
2972  } else {
2973  }
2974  // insert custom user-set cURL options
2975  foreach ($this->ch_options as $key => $val) {
2976  $this->setCurlOption($key, $val);
2977  }
2978 
2979  $this->debug('set cURL payload');
2980  return true;
2981  }
2982  }
setError($str)
sets error string
Definition: nusoap.php:395
buildPayload($data, $cookie_str='')
Writes the payload, including HTTP headers, to $this->outgoing_payload.
Definition: nusoap.php:2884
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
setCurlOption($option, $value)
sets a cURL option
Definition: nusoap.php:2253
getCookiesForRequest($cookies, $secure=false)
sort out cookies for the current request
Definition: nusoap.php:3467
string $key
Consumer key/client ID value.
Definition: System.php:193
io_method()
gets the I/O method to use
Definition: nusoap.php:2338
+ Here is the call graph for this function:

◆ setContentType()

soap_transport_http::setContentType (   $type,
  $charset = false 
)

sets the content-type for the SOAP message to be sent

Parameters
string$typethe content type, MIME style
mixed$charsetcharacter set used for encoding (or false) public

Definition at line 3368 of file nusoap.php.

References $type.

3369  {
3370  $this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : ''));
3371  }
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2267
$type

◆ setCredentials()

soap_transport_http::setCredentials (   $username,
  $password,
  $authtype = 'basic',
  $digestRequest = array(),
  $certRequest = array() 
)

if authenticating, set user credentials here

Parameters
string$username
string$password
string$authtype(basic|digest|certificate|ntlm)
array$digestRequest(keys must be nonce, nc, realm, qop)
array$certRequest(keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) public

Definition at line 2656 of file nusoap.php.

References nusoap_base\appendDebug(), nusoap_base\debug(), and nusoap_base\varDump().

2657  {
2658  $this->debug("setCredentials username=$username authtype=$authtype digestRequest=");
2659  $this->appendDebug($this->varDump($digestRequest));
2660  $this->debug("certRequest=");
2661  $this->appendDebug($this->varDump($certRequest));
2662  // cf. RFC 2617
2663  if ($authtype == 'basic') {
2664  $this->setHeader('Authorization', 'Basic ' . base64_encode(str_replace(':', '', $username) . ':' . $password));
2665  } elseif ($authtype == 'digest') {
2666  if (isset($digestRequest['nonce'])) {
2667  $digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1;
2668 
2669  // calculate the Digest hashes (calculate code based on digest implementation found at: http://www.rassoc.com/gregr/weblog/stories/2002/07/09/webServicesSecurityHttpDigestAuthenticationWithoutActiveDirectory.html)
2670 
2671  // A1 = unq(username-value) ":" unq(realm-value) ":" passwd
2672  $A1 = $username . ':' . (isset($digestRequest['realm']) ? $digestRequest['realm'] : '') . ':' . $password;
2673 
2674  // H(A1) = MD5(A1)
2675  $HA1 = md5($A1);
2676 
2677  // A2 = Method ":" digest-uri-value
2678  $A2 = $this->request_method . ':' . $this->digest_uri;
2679 
2680  // H(A2)
2681  $HA2 = md5($A2);
2682 
2683  // KD(secret, data) = H(concat(secret, ":", data))
2684  // if qop == auth:
2685  // request-digest = <"> < KD ( H(A1), unq(nonce-value)
2686  // ":" nc-value
2687  // ":" unq(cnonce-value)
2688  // ":" unq(qop-value)
2689  // ":" H(A2)
2690  // ) <">
2691  // if qop is missing,
2692  // request-digest = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <">
2693 
2694  $unhashedDigest = '';
2695  $nonce = isset($digestRequest['nonce']) ? $digestRequest['nonce'] : '';
2696  $cnonce = $nonce;
2697  if ($digestRequest['qop'] != '') {
2698  $unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf("%08d", $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2;
2699  } else {
2700  $unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2;
2701  }
2702 
2703  $hashedDigest = md5($unhashedDigest);
2704 
2705  $opaque = '';
2706  if (isset($digestRequest['opaque'])) {
2707  $opaque = ', opaque="' . $digestRequest['opaque'] . '"';
2708  }
2709 
2710  $this->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . $digestRequest['realm'] . '", nonce="' . $nonce . '", uri="' . $this->digest_uri . $opaque . '", cnonce="' . $cnonce . '", nc=' . sprintf("%08x", $digestRequest['nc']) . ', qop="' . $digestRequest['qop'] . '", response="' . $hashedDigest . '"');
2711  }
2712  } elseif ($authtype == 'certificate') {
2713  $this->certRequest = $certRequest;
2714  $this->debug('Authorization header not set for certificate');
2715  } elseif ($authtype == 'ntlm') {
2716  // do nothing
2717  $this->debug('Authorization header not set for ntlm');
2718  }
2719  $this->username = $username;
2720  $this->password = $password;
2721  $this->authtype = $authtype;
2722  $this->digestRequest = $digestRequest;
2723  }
appendDebug($string)
adds debug data to the instance debug string without formatting
Definition: nusoap.php:305
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2267
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
varDump($data)
Returns a string with the output of var_dump.
Definition: nusoap.php:909
+ Here is the call graph for this function:

◆ setCurlOption()

soap_transport_http::setCurlOption (   $option,
  $value 
)

sets a cURL option

Parameters
mixed$optionThe cURL option (always integer?)
mixed$valueThe cURL option value private

Definition at line 2253 of file nusoap.php.

References nusoap_base\appendDebug(), nusoap_base\debug(), and nusoap_base\varDump().

2254  {
2255  $this->debug("setCurlOption option=$option, value=");
2256  $this->appendDebug($this->varDump($value));
2257  curl_setopt($this->ch, $option, $value);
2258  }
appendDebug($string)
adds debug data to the instance debug string without formatting
Definition: nusoap.php:305
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
varDump($data)
Returns a string with the output of var_dump.
Definition: nusoap.php:909
+ Here is the call graph for this function:

◆ setEncoding()

soap_transport_http::setEncoding (   $enc = 'gzip,
deflate'   
)

use http encoding

Parameters
string$encencoding style. supported values: gzip, deflate, or both public

Definition at line 2742 of file nusoap.php.

2743  {
2744  if (function_exists('gzdeflate')) {
2745  $this->protocol_version = '1.1';
2746  $this->setHeader('Accept-Encoding', $enc);
2747  if (!isset($this->outgoing_headers['Connection'])) {
2748  $this->setHeader('Connection', 'close');
2749  $this->persistentConnection = false;
2750  }
2751  #set_magic_quotes_runtime(0);
2752  // deprecated
2753  $this->encoding = $enc;
2754  }
2755  }
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2267

◆ setHeader()

soap_transport_http::setHeader (   $name,
  $value 
)

sets an HTTP header

Parameters
string$nameThe name of the header
string$valueThe value of the header private

Definition at line 2267 of file nusoap.php.

References $name, and nusoap_base\debug().

2268  {
2269  $this->outgoing_headers[$name] = $value;
2270  $this->debug("set header $name: $value");
2271  }
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
if($format !==null) $name
Definition: metadata.php:247
+ Here is the call graph for this function:

◆ setProxy()

soap_transport_http::setProxy (   $proxyhost,
  $proxyport,
  $proxyusername = '',
  $proxypassword = '',
  $proxyauthtype = 'basic' 
)

set proxy info here

Parameters
string$proxyhostuse an empty string to remove proxy
string$proxyport
string$proxyusername
string$proxypassword
string$proxyauthtype(basic|ntlm) public

Definition at line 2767 of file nusoap.php.

References nusoap_base\debug().

2768  {
2769  if ($proxyhost) {
2770  $this->proxy = array(
2771  'host' => $proxyhost,
2772  'port' => $proxyport,
2773  'username' => $proxyusername,
2774  'password' => $proxypassword,
2775  'authtype' => $proxyauthtype
2776  );
2777  if ($proxyusername != '' && $proxypassword != '' && $proxyauthtype = 'basic') {
2778  $this->setHeader('Proxy-Authorization', ' Basic ' . base64_encode($proxyusername . ':' . $proxypassword));
2779  }
2780  } else {
2781  $this->debug('remove proxy');
2782  $proxy = null;
2783  unsetHeader('Proxy-Authorization');
2784  }
2785  }
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2267
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
unsetHeader($name)
unsets an HTTP header
Definition: nusoap.php:2279
+ Here is the call graph for this function:

◆ setSOAPAction()

soap_transport_http::setSOAPAction (   $soapaction)

set the soapaction value

Parameters
string$soapactionpublic

Definition at line 2731 of file nusoap.php.

2732  {
2733  $this->setHeader('SOAPAction', '"' . $soapaction . '"');
2734  }
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2267

◆ setURL()

soap_transport_http::setURL (   $url)

sets the URL to which to connect

Parameters
string$urlThe URL to which to connect private

Definition at line 2293 of file nusoap.php.

References $path, $url, and nusoap_base\debug().

2294  {
2295  $this->url = $url;
2296 
2297  $u = parse_url($url);
2298  foreach ($u as $k => $v) {
2299  $this->debug("parsed URL $k = $v");
2300  $this->$k = $v;
2301  }
2302 
2303  // add any GET params to path
2304  if (isset($u['query']) && $u['query'] != '') {
2305  $this->path .= '?' . $u['query'];
2306  }
2307 
2308  // set default port
2309  if (!isset($u['port'])) {
2310  if ($u['scheme'] == 'https') {
2311  $this->port = 443;
2312  } else {
2313  $this->port = 80;
2314  }
2315  }
2316 
2317  $this->uri = $this->path;
2318  $this->digest_uri = $this->uri;
2319 
2320  // build headers
2321  if (!isset($u['port'])) {
2322  $this->setHeader('Host', $this->host);
2323  } else {
2324  $this->setHeader('Host', $this->host . ':' . $this->port);
2325  }
2326 
2327  if (isset($u['user']) && $u['user'] != '') {
2328  $this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : '');
2329  }
2330  }
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2267
setCredentials($username, $password, $authtype='basic', $digestRequest=array(), $certRequest=array())
if authenticating, set user credentials here
Definition: nusoap.php:2656
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
+ Here is the call graph for this function:

◆ unsetHeader()

soap_transport_http::unsetHeader (   $name)

unsets an HTTP header

Parameters
string$nameThe name of the header private

Definition at line 2279 of file nusoap.php.

References $name, and nusoap_base\debug().

2280  {
2281  if (isset($this->outgoing_headers[$name])) {
2282  $this->debug("unset header $name");
2283  unset($this->outgoing_headers[$name]);
2284  }
2285  }
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
if($format !==null) $name
Definition: metadata.php:247
+ Here is the call graph for this function:

◆ usePersistentConnection()

soap_transport_http::usePersistentConnection ( )

specifies that an HTTP persistent connection should be used

Returns
boolean whether the request was honored by this method. public

Definition at line 3379 of file nusoap.php.

3380  {
3381  if (isset($this->outgoing_headers['Accept-Encoding'])) {
3382  return false;
3383  }
3384  $this->protocol_version = '1.1';
3385  $this->persistentConnection = true;
3386  $this->setHeader('Connection', 'Keep-Alive');
3387  return true;
3388  }
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2267

Field Documentation

◆ $authtype

soap_transport_http::$authtype = ''

Definition at line 2212 of file nusoap.php.

◆ $certRequest

soap_transport_http::$certRequest = array()

Definition at line 2214 of file nusoap.php.

◆ $ch

soap_transport_http::$ch = false

Definition at line 2206 of file nusoap.php.

◆ $ch_options

soap_transport_http::$ch_options = array()

Definition at line 2207 of file nusoap.php.

◆ $digest_uri

soap_transport_http::$digest_uri = ''

Definition at line 2190 of file nusoap.php.

◆ $digestRequest

soap_transport_http::$digestRequest = array()

Definition at line 2213 of file nusoap.php.

◆ $encoding

soap_transport_http::$encoding = ''

Definition at line 2197 of file nusoap.php.

◆ $host

soap_transport_http::$host = ''

Definition at line 2192 of file nusoap.php.

◆ $incoming_cookies

soap_transport_http::$incoming_cookies = array()

Definition at line 2200 of file nusoap.php.

◆ $incoming_headers

soap_transport_http::$incoming_headers = array()

Definition at line 2199 of file nusoap.php.

◆ $incoming_payload

soap_transport_http::$incoming_payload = ''

Definition at line 2202 of file nusoap.php.

◆ $outgoing_headers

soap_transport_http::$outgoing_headers = array()

Definition at line 2198 of file nusoap.php.

◆ $outgoing_payload

soap_transport_http::$outgoing_payload = ''

Definition at line 2201 of file nusoap.php.

◆ $password

soap_transport_http::$password = ''

Definition at line 2211 of file nusoap.php.

◆ $path

soap_transport_http::$path = ''

Definition at line 2194 of file nusoap.php.

◆ $persistentConnection

soap_transport_http::$persistentConnection = false

Definition at line 2205 of file nusoap.php.

◆ $port

soap_transport_http::$port = ''

Definition at line 2193 of file nusoap.php.

◆ $protocol_version

soap_transport_http::$protocol_version = '1.0'

Definition at line 2196 of file nusoap.php.

◆ $proxy

soap_transport_http::$proxy = null

Definition at line 2209 of file nusoap.php.

◆ $request_method

soap_transport_http::$request_method = 'POST'

Definition at line 2195 of file nusoap.php.

◆ $response_status_line

soap_transport_http::$response_status_line

Definition at line 2203 of file nusoap.php.

◆ $scheme

soap_transport_http::$scheme = ''

Definition at line 2191 of file nusoap.php.

◆ $uri

soap_transport_http::$uri = ''

Definition at line 2189 of file nusoap.php.

◆ $url

soap_transport_http::$url = ''

Definition at line 2188 of file nusoap.php.

◆ $use_curl

soap_transport_http::$use_curl = false

Definition at line 2208 of file nusoap.php.

◆ $username

soap_transport_http::$username = ''

Definition at line 2210 of file nusoap.php.

◆ $useSOAPAction

soap_transport_http::$useSOAPAction = true

Definition at line 2204 of file nusoap.php.


The documentation for this class was generated from the following file: