ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
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

 $fp
 
 $tryagain
 
 $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$ @access public

Definition at line 2138 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 @access public

Definition at line 2185 of file nusoap.php.

2186 {
2188 $this->debug("ctor url=$url use_curl=$use_curl curl_options:");
2189 $this->appendDebug($this->varDump($curl_options));
2190 $this->setURL($url);
2191 if (is_array($curl_options)) {
2192 $this->ch_options = $curl_options;
2193 }
2194 $this->use_curl = $use_curl;
2195 preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
2196 // begin-patch php8
2197 $this->setHeader('User-Agent', $this->title . '/' . $this->version . ' (' . ($rev[1] ?? '1.1') . ')');
2198 }
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:250
varDump($data)
Returns a string with the output of var_dump.
Definition: nusoap.php:867
appendDebug($string)
adds debug data to the instance debug string without formatting
Definition: nusoap.php:263
setURL($url)
sets the URL to which to connect
Definition: nusoap.php:2247
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2221
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ 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 @access private

Definition at line 2838 of file nusoap.php.

2839 {
2840 // Note: for cURL connections, $this->outgoing_payload is ignored,
2841 // as is the Content-Length header, but these are still created as
2842 // debugging guides.
2843
2844 // add content-length header
2845 $this->setHeader('Content-Length', strlen($data));
2846
2847 // start building outgoing payload:
2848 if ($this->proxy) {
2849 $uri = $this->url;
2850 } else {
2851 $uri = $this->uri;
2852 }
2853 $req = "$this->request_method $uri HTTP/$this->protocol_version";
2854 $this->debug("HTTP request: $req");
2855 $this->outgoing_payload = "$req\r\n";
2856
2857 // loop thru headers, serializing
2858 foreach ($this->outgoing_headers as $k => $v) {
2859 $hdr = $k . ': ' . $v;
2860 $this->debug("HTTP header: $hdr");
2861 $this->outgoing_payload .= "$hdr\r\n";
2862 }
2863
2864 // add any cookies
2865 if ($cookie_str != '') {
2866 $hdr = 'Cookie: ' . $cookie_str;
2867 $this->debug("HTTP header: $hdr");
2868 $this->outgoing_payload .= "$hdr\r\n";
2869 }
2870
2871 // header/body separator
2872 $this->outgoing_payload .= "\r\n";
2873
2874 // add data
2875 $this->outgoing_payload .= $data;
2876 }
catch(\Exception $e) $req
Definition: xapiproxy.php:78

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

Referenced by sendRequest().

+ Here is the call graph for this function:
+ Here is the caller 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 @access private

Definition at line 2311 of file nusoap.php.

2312 {
2313 // For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like
2314 // "regular" socket.
2315 // TODO: disabled for now because OpenSSL must be *compiled* in (not just
2316 // loaded), and until PHP5 stream_get_wrappers is not available.
2317 // if ($this->scheme == 'https') {
2318 // if (version_compare(phpversion(), '4.3.0') >= 0) {
2319 // if (extension_loaded('openssl')) {
2320 // $this->scheme = 'ssl';
2321 // $this->debug('Using SSL over OpenSSL');
2322 // }
2323 // }
2324 // }
2325 $this->debug("connect connection_timeout $connection_timeout, response_timeout $response_timeout, scheme $this->scheme, host $this->host, port $this->port");
2326 if ($this->io_method() == 'socket') {
2327 if (!is_array($this->proxy)) {
2330 } else {
2331 $host = $this->proxy['host'];
2332 $port = $this->proxy['port'];
2333 }
2334
2335 // use persistent connection
2336 if ($this->persistentConnection && isset($this->fp) && is_resource($this->fp)) {
2337 if (!feof($this->fp)) {
2338 $this->debug('Re-use persistent connection');
2339 return true;
2340 }
2341 fclose($this->fp);
2342 $this->debug('Closed persistent connection at EOF');
2343 }
2344
2345 // munge host if using OpenSSL
2346 if ($this->scheme == 'ssl') {
2347 $host = 'ssl://' . $host;
2348 }
2349 $this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout);
2350
2351 // open socket
2352 if ($connection_timeout > 0) {
2353 $this->fp = @fsockopen($host, $this->port, $this->errno, $this->error_str, $connection_timeout);
2354 } else {
2355 $this->fp = @fsockopen($host, $this->port, $this->errno, $this->error_str);
2356 }
2357
2358 // test pointer
2359 if (!$this->fp) {
2360 $msg = 'Couldn\'t open socket connection to server ' . $this->url;
2361 if ($this->errno) {
2362 $msg .= ', Error (' . $this->errno . '): ' . $this->error_str;
2363 } else {
2364 $msg .= ' prior to connect(). This is often a problem looking up the host name.';
2365 }
2366 $this->debug($msg);
2367 $this->setError($msg);
2368 return false;
2369 }
2370
2371 // set response timeout
2372 $this->debug('set response timeout to ' . $response_timeout);
2373 socket_set_timeout($this->fp, $response_timeout);
2374
2375 $this->debug('socket connected');
2376 return true;
2377 } elseif ($this->io_method() == 'curl') {
2378 if (!extension_loaded('curl')) {
2379 // $this->setError('cURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS');
2380 $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.');
2381 return false;
2382 }
2383 // Avoid warnings when PHP does not have these options
2384 if (defined('CURLOPT_CONNECTIONTIMEOUT')) {
2385 $CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT;
2386 } else {
2387 $CURLOPT_CONNECTIONTIMEOUT = 78;
2388 }
2389 if (defined('CURLOPT_HTTPAUTH')) {
2390 $CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH;
2391 } else {
2392 $CURLOPT_HTTPAUTH = 107;
2393 }
2394 if (defined('CURLOPT_PROXYAUTH')) {
2395 $CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH;
2396 } else {
2397 $CURLOPT_PROXYAUTH = 111;
2398 }
2399 if (defined('CURLAUTH_BASIC')) {
2400 $CURLAUTH_BASIC = CURLAUTH_BASIC;
2401 } else {
2402 $CURLAUTH_BASIC = 1;
2403 }
2404 if (defined('CURLAUTH_DIGEST')) {
2405 $CURLAUTH_DIGEST = CURLAUTH_DIGEST;
2406 } else {
2407 $CURLAUTH_DIGEST = 2;
2408 }
2409 if (defined('CURLAUTH_NTLM')) {
2410 $CURLAUTH_NTLM = CURLAUTH_NTLM;
2411 } else {
2412 $CURLAUTH_NTLM = 8;
2413 }
2414
2415 $this->debug('connect using cURL');
2416 // init CURL
2417 $this->ch = curl_init();
2418 // set url
2419 $hostURL = ($this->port != '') ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$this->host";
2420 // add path
2421 $hostURL .= $this->path;
2422 $this->setCurlOption(CURLOPT_URL, $hostURL);
2423 // follow location headers (re-directs)
2424 if (ini_get('safe_mode') || ini_get('open_basedir')) {
2425 $this->debug('safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION');
2426 $this->debug('safe_mode = ');
2427 $this->appendDebug($this->varDump(ini_get('safe_mode')));
2428 $this->debug('open_basedir = ');
2429 $this->appendDebug($this->varDump(ini_get('open_basedir')));
2430 } else {
2431 $this->setCurlOption(CURLOPT_FOLLOWLOCATION, 1);
2432 }
2433 // ask for headers in the response output
2434 $this->setCurlOption(CURLOPT_HEADER, 1);
2435 // ask for the response output as the return value
2436 $this->setCurlOption(CURLOPT_RETURNTRANSFER, 1);
2437 // encode
2438 // We manage this ourselves through headers and encoding
2439 // if(function_exists('gzuncompress')){
2440 // $this->setCurlOption(CURLOPT_ENCODING, 'deflate');
2441 // }
2442 // persistent connection
2443 if ($this->persistentConnection) {
2444 // I believe the following comment is now bogus, having applied to
2445 // the code when it used CURLOPT_CUSTOMREQUEST to send the request.
2446 // The way we send data, we cannot use persistent connections, since
2447 // there will be some "junk" at the end of our request.
2448 //$this->setCurlOption(CURL_HTTP_VERSION_1_1, true);
2449 $this->persistentConnection = false;
2450 $this->setHeader('Connection', 'close');
2451 }
2452 // set timeouts
2453 if ($connection_timeout != 0) {
2454 $this->setCurlOption($CURLOPT_CONNECTIONTIMEOUT, $connection_timeout);
2455 }
2456 if ($response_timeout != 0) {
2457 $this->setCurlOption(CURLOPT_TIMEOUT, $response_timeout);
2458 }
2459
2460 if ($this->scheme == 'https') {
2461 $this->debug('set cURL SSL verify options');
2462 // recent versions of cURL turn on peer/host checking by default,
2463 // while PHP binaries are not compiled with a default location for the
2464 // CA cert bundle, so disable peer/host checking.
2465 //$this->setCurlOption(CURLOPT_CAINFO, 'f:\php-4.3.2-win32\extensions\curl-ca-bundle.crt');
2466 $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
2467 $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0);
2468
2469 // support client certificates (thanks Tobias Boes, Doug Anarino, Eryan Ariobowo)
2470 if ($this->authtype == 'certificate') {
2471 $this->debug('set cURL certificate options');
2472 if (isset($this->certRequest['cainfofile'])) {
2473 $this->setCurlOption(CURLOPT_CAINFO, $this->certRequest['cainfofile']);
2474 }
2475 if (isset($this->certRequest['verifypeer'])) {
2476 $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, $this->certRequest['verifypeer']);
2477 } else {
2478 $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 1);
2479 }
2480 if (isset($this->certRequest['verifyhost'])) {
2481 $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, $this->certRequest['verifyhost']);
2482 } else {
2483 $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1);
2484 }
2485 if (isset($this->certRequest['sslcertfile'])) {
2486 $this->setCurlOption(CURLOPT_SSLCERT, $this->certRequest['sslcertfile']);
2487 }
2488 if (isset($this->certRequest['sslkeyfile'])) {
2489 $this->setCurlOption(CURLOPT_SSLKEY, $this->certRequest['sslkeyfile']);
2490 }
2491 if (isset($this->certRequest['passphrase'])) {
2492 $this->setCurlOption(CURLOPT_SSLKEYPASSWD, $this->certRequest['passphrase']);
2493 }
2494 if (isset($this->certRequest['certpassword'])) {
2495 $this->setCurlOption(CURLOPT_SSLCERTPASSWD, $this->certRequest['certpassword']);
2496 }
2497 }
2498 }
2499 if ($this->authtype && ($this->authtype != 'certificate')) {
2500 if ($this->username) {
2501 $this->debug('set cURL username/password');
2502 $this->setCurlOption(CURLOPT_USERPWD, "$this->username:$this->password");
2503 }
2504 if ($this->authtype == 'basic') {
2505 $this->debug('set cURL for Basic authentication');
2506 $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_BASIC);
2507 }
2508 if ($this->authtype == 'digest') {
2509 $this->debug('set cURL for digest authentication');
2510 $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_DIGEST);
2511 }
2512 if ($this->authtype == 'ntlm') {
2513 $this->debug('set cURL for NTLM authentication');
2514 $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_NTLM);
2515 }
2516 }
2517 if (is_array($this->proxy)) {
2518 $this->debug('set cURL proxy options');
2519 if ($this->proxy['port'] != '') {
2520 $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host'] . ':' . $this->proxy['port']);
2521 } else {
2522 $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host']);
2523 }
2524 if ($this->proxy['username'] || $this->proxy['password']) {
2525 $this->debug('set cURL proxy authentication options');
2526 $this->setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy['username'] . ':' . $this->proxy['password']);
2527 if ($this->proxy['authtype'] == 'basic') {
2528 $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_BASIC);
2529 }
2530 if ($this->proxy['authtype'] == 'ntlm') {
2531 $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_NTLM);
2532 }
2533 }
2534 }
2535 $this->debug('cURL connection set up');
2536 return true;
2537 } else {
2538 $this->setError('Unknown scheme ' . $this->scheme);
2539 $this->debug('Unknown scheme ' . $this->scheme);
2540 return false;
2541 }
2542 }
setError($str)
sets error string
Definition: nusoap.php:353
setCurlOption($option, $value)
sets a cURL option
Definition: nusoap.php:2207
io_method()
gets the I/O method to use
Definition: nusoap.php:2292

References nusoap_base\$error_str, $host, $path, $port, $url, nusoap_base\appendDebug(), nusoap_base\debug(), io_method(), setCurlOption(), nusoap_base\setError(), setHeader(), and nusoap_base\varDump().

Referenced by send().

+ Here is the call graph for this function:
+ Here is the caller 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 @access public
Deprecated:

Definition at line 2780 of file nusoap.php.

2781 {
2782 // length := 0
2783 $length = 0;
2784 $new = '';
2785
2786 // read chunk-size, chunk-extension (if any) and CRLF
2787 // get the position of the linebreak
2788 $chunkend = strpos($buffer, $lb);
2789 if ($chunkend == false) {
2790 $this->debug('no linebreak found in decodeChunked');
2791 return $new;
2792 }
2793 $temp = substr($buffer, 0, $chunkend);
2794 $chunk_size = hexdec(trim($temp));
2795 $chunkstart = $chunkend + strlen($lb);
2796 // while (chunk-size > 0) {
2797 while ($chunk_size > 0) {
2798 $this->debug("chunkstart: $chunkstart chunk_size: $chunk_size");
2799 $chunkend = strpos($buffer, $lb, $chunkstart + $chunk_size);
2800
2801 // Just in case we got a broken connection
2802 if ($chunkend == false) {
2803 $chunk = substr($buffer, $chunkstart);
2804 // append chunk-data to entity-body
2805 $new .= $chunk;
2806 $length += strlen($chunk);
2807 break;
2808 }
2809
2810 // read chunk-data and CRLF
2811 $chunk = substr($buffer, $chunkstart, $chunkend - $chunkstart);
2812 // append chunk-data to entity-body
2813 $new .= $chunk;
2814 // length := length + chunk-size
2815 $length += strlen($chunk);
2816 // read chunk-size and CRLF
2817 $chunkstart = $chunkend + strlen($lb);
2818
2819 $chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb);
2820 if ($chunkend == false) {
2821 break; //Just in case we got a broken connection
2822 }
2823 $temp = substr($buffer, $chunkstart, $chunkend - $chunkstart);
2824 $chunk_size = hexdec(trim($temp));
2825 $chunkstart = $chunkend;
2826 }
2827 return $new;
2828 }

References nusoap_base\debug().

+ 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 @access private

Definition at line 3420 of file nusoap.php.

3421 {
3422 $cookie_str = '';
3423 if ((! is_null($cookies)) && (is_array($cookies))) {
3424 foreach ($cookies as $cookie) {
3425 if (! is_array($cookie)) {
3426 continue;
3427 }
3428 $this->debug("check cookie for validity: " . $cookie['name'] . '=' . $cookie['value']);
3429 if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
3430 if (strtotime($cookie['expires']) <= time()) {
3431 $this->debug('cookie has expired');
3432 continue;
3433 }
3434 }
3435 if ((isset($cookie['domain'])) && (! empty($cookie['domain']))) {
3436 $domain = preg_quote($cookie['domain']);
3437 if (! preg_match("'.*$domain$'i", $this->host)) {
3438 $this->debug('cookie has different domain');
3439 continue;
3440 }
3441 }
3442 if ((isset($cookie['path'])) && (! empty($cookie['path']))) {
3443 $path = preg_quote($cookie['path']);
3444 if (! preg_match("'^$path.*'i", $this->path)) {
3445 $this->debug('cookie is for a different path');
3446 continue;
3447 }
3448 }
3449 if ((! $secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
3450 $this->debug('cookie is secure, transport is not');
3451 continue;
3452 }
3453 $cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; ';
3454 $this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
3455 }
3456 }
3457 return $cookie_str;
3458 }

References $path, and nusoap_base\debug().

Referenced by sendRequest().

+ Here is the call graph for this function:
+ Here is the caller 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) @access private

Definition at line 2944 of file nusoap.php.

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

References $data, $digestRequest, $incoming_payload, nusoap_base\debug(), io_method(), isSkippableCurlHeader(), parseCookie(), setCredentials(), nusoap_base\setError(), and setURL().

Referenced by send().

+ Here is the call graph for this function:
+ Here is the caller 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) @access private

Definition at line 2292 of file nusoap.php.

2293 {
2294 if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm')) {
2295 return 'curl';
2296 }
2297 if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm')) {
2298 return 'socket';
2299 }
2300 return 'unknown';
2301 }

Referenced by connect(), getResponse(), and sendRequest().

+ Here is the caller graph for this function:

◆ 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. @access private

Definition at line 2750 of file nusoap.php.

2751 {
2752 $skipHeaders = array( 'HTTP/1.1 100',
2753 'HTTP/1.0 301',
2754 'HTTP/1.1 301',
2755 'HTTP/1.0 302',
2756 'HTTP/1.1 302',
2757 'HTTP/1.0 401',
2758 'HTTP/1.1 401',
2759 'HTTP/1.0 200 Connection established');
2760 foreach ($skipHeaders as $hd) {
2761 $prefix = substr($data, 0, strlen($hd));
2762 if ($prefix == $hd) {
2763 return true;
2764 }
2765 }
2766
2767 return false;
2768 }

References $data.

Referenced by getResponse().

+ Here is the caller graph for this function:

◆ 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 @access private

Definition at line 3353 of file nusoap.php.

3354 {
3355 $cookie_str = str_replace('; ', ';', $cookie_str) . ';';
3356 // begin-patch php8
3357 //$data = split(';', $cookie_str);
3358 $data = explode(';', $cookie_str);
3359 $value_str = $data[0];
3360
3361 $cookie_param = 'domain=';
3362 $start = strpos($cookie_str, $cookie_param);
3363 if ($start > 0) {
3364 $domain = substr($cookie_str, $start + strlen($cookie_param));
3365 $domain = substr($domain, 0, strpos($domain, ';'));
3366 } else {
3367 $domain = '';
3368 }
3369
3370 $cookie_param = 'expires=';
3371 $start = strpos($cookie_str, $cookie_param);
3372 if ($start > 0) {
3373 $expires = substr($cookie_str, $start + strlen($cookie_param));
3374 $expires = substr($expires, 0, strpos($expires, ';'));
3375 } else {
3376 $expires = '';
3377 }
3378
3379 $cookie_param = 'path=';
3380 $start = strpos($cookie_str, $cookie_param);
3381 if ($start > 0) {
3382 $path = substr($cookie_str, $start + strlen($cookie_param));
3383 $path = substr($path, 0, strpos($path, ';'));
3384 } else {
3385 $path = '/';
3386 }
3387
3388 $cookie_param = ';secure;';
3389 if (strpos($cookie_str, $cookie_param) !== false) {
3390 $secure = true;
3391 } else {
3392 $secure = false;
3393 }
3394
3395 $sep_pos = strpos($value_str, '=');
3396
3397 if ($sep_pos) {
3398 $name = substr($value_str, 0, $sep_pos);
3399 $value = substr($value_str, $sep_pos + 1);
3400 $cookie = array( 'name' => $name,
3401 'value' => $value,
3402 'domain' => $domain,
3403 'path' => $path,
3404 'expires' => $expires,
3405 'secure' => $secure
3406 );
3407 return $cookie;
3408 }
3409 return false;
3410 }

References $data, and $path.

Referenced by getResponse().

+ Here is the caller graph for this function:

◆ 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 @access public

Definition at line 2554 of file nusoap.php.

2555 {
2556 $this->debug('entered send() with data of length: ' . strlen($data));
2557
2558 $this->tryagain = true;
2559 $tries = 0;
2560 while ($this->tryagain) {
2561 $this->tryagain = false;
2562 if ($tries++ < 2) {
2563 // make connnection
2564 if (!$this->connect($timeout, $response_timeout)) {
2565 return false;
2566 }
2567
2568 // send request
2569 if (!$this->sendRequest($data, $cookies)) {
2570 return false;
2571 }
2572
2573 // get response
2574 $respdata = $this->getResponse();
2575 } else {
2576 $this->setError("Too many tries to get an OK response ($this->response_status_line)");
2577 }
2578 }
2579 $this->debug('end of send()');
2580 return $respdata;
2581 }
sendRequest($data, $cookies=null)
sends the SOAP request via HTTP[S]
Definition: nusoap.php:2886
getResponse()
gets the SOAP response via HTTP[S]
Definition: nusoap.php:2944
connect($connection_timeout=0, $response_timeout=30)
establish an HTTP connection
Definition: nusoap.php:2311

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

Referenced by sendHTTPS().

+ Here is the call graph for this function:
+ Here is the caller 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 @access public
Deprecated:

Definition at line 2595 of file nusoap.php.

2596 {
2597 return $this->send($data, $timeout, $response_timeout, $cookies);
2598 }
send($data, $timeout=0, $response_timeout=30, $cookies=null)
sends the SOAP request and gets the SOAP response via HTTP[S]
Definition: nusoap.php:2554

References $data, and send().

+ 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 @access private

Definition at line 2886 of file nusoap.php.

2887 {
2888 // build cookie string
2889 $cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https')));
2890
2891 // build payload
2892 $this->buildPayload($data, $cookie_str);
2893
2894 if ($this->io_method() == 'socket') {
2895 // send payload
2896 if (!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
2897 $this->setError('couldn\'t write message data to socket');
2898 $this->debug('couldn\'t write message data to socket');
2899 return false;
2900 }
2901 $this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
2902 return true;
2903 } elseif ($this->io_method() == 'curl') {
2904 // set payload
2905 // cURL does say this should only be the verb, and in fact it
2906 // turns out that the URI and HTTP version are appended to this, which
2907 // some servers refuse to work with (so we no longer use this method!)
2908 //$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload);
2909 $curl_headers = array();
2910 foreach ($this->outgoing_headers as $k => $v) {
2911 if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') {
2912 $this->debug("Skip cURL header $k: $v");
2913 } else {
2914 $curl_headers[] = "$k: $v";
2915 }
2916 }
2917 if ($cookie_str != '') {
2918 $curl_headers[] = 'Cookie: ' . $cookie_str;
2919 }
2920 $this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers);
2921 $this->debug('set cURL HTTP headers');
2922 if ($this->request_method == "POST") {
2923 $this->setCurlOption(CURLOPT_POST, 1);
2924 $this->setCurlOption(CURLOPT_POSTFIELDS, $data);
2925 $this->debug('set cURL POST data');
2926 } else {
2927 }
2928 // insert custom user-set cURL options
2929 foreach ($this->ch_options as $key => $val) {
2930 $this->setCurlOption($key, $val);
2931 }
2932
2933 $this->debug('set cURL payload');
2934 return true;
2935 }
2936 }
getCookiesForRequest($cookies, $secure=false)
sort out cookies for the current request
Definition: nusoap.php:3420
buildPayload($data, $cookie_str='')
Writes the payload, including HTTP headers, to $this->outgoing_payload.
Definition: nusoap.php:2838

References $data, buildPayload(), nusoap_base\debug(), getCookiesForRequest(), io_method(), setCurlOption(), and nusoap_base\setError().

Referenced by send().

+ Here is the call graph for this function:
+ Here is the caller 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) @access public

Definition at line 3321 of file nusoap.php.

3322 {
3323 $this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : ''));
3324 }

References setHeader().

+ Here is the call graph for this function:

◆ 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) @access public

Definition at line 2610 of file nusoap.php.

2611 {
2612 $this->debug("setCredentials username=$username authtype=$authtype digestRequest=");
2613 $this->appendDebug($this->varDump($digestRequest));
2614 $this->debug("certRequest=");
2615 $this->appendDebug($this->varDump($certRequest));
2616 // cf. RFC 2617
2617 if ($authtype == 'basic') {
2618 $this->setHeader('Authorization', 'Basic ' . base64_encode(str_replace(':', '', $username) . ':' . $password));
2619 } elseif ($authtype == 'digest') {
2620 if (isset($digestRequest['nonce'])) {
2621 $digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1;
2622
2623 // calculate the Digest hashes (calculate code based on digest implementation found at: http://www.rassoc.com/gregr/weblog/stories/2002/07/09/webServicesSecurityHttpDigestAuthenticationWithoutActiveDirectory.html)
2624
2625 // A1 = unq(username-value) ":" unq(realm-value) ":" passwd
2626 $A1 = $username . ':' . (isset($digestRequest['realm']) ? $digestRequest['realm'] : '') . ':' . $password;
2627
2628 // H(A1) = MD5(A1)
2629 $HA1 = md5($A1);
2630
2631 // A2 = Method ":" digest-uri-value
2632 $A2 = $this->request_method . ':' . $this->digest_uri;
2633
2634 // H(A2)
2635 $HA2 = md5($A2);
2636
2637 // KD(secret, data) = H(concat(secret, ":", data))
2638 // if qop == auth:
2639 // request-digest = <"> < KD ( H(A1), unq(nonce-value)
2640 // ":" nc-value
2641 // ":" unq(cnonce-value)
2642 // ":" unq(qop-value)
2643 // ":" H(A2)
2644 // ) <">
2645 // if qop is missing,
2646 // request-digest = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <">
2647
2648 $unhashedDigest = '';
2649 $nonce = isset($digestRequest['nonce']) ? $digestRequest['nonce'] : '';
2650 $cnonce = $nonce;
2651 if ($digestRequest['qop'] != '') {
2652 $unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf("%08d", $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2;
2653 } else {
2654 $unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2;
2655 }
2656
2657 $hashedDigest = md5($unhashedDigest);
2658
2659 $opaque = '';
2660 if (isset($digestRequest['opaque'])) {
2661 $opaque = ', opaque="' . $digestRequest['opaque'] . '"';
2662 }
2663
2664 $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 . '"');
2665 }
2666 } elseif ($authtype == 'certificate') {
2667 $this->certRequest = $certRequest;
2668 $this->debug('Authorization header not set for certificate');
2669 } elseif ($authtype == 'ntlm') {
2670 // do nothing
2671 $this->debug('Authorization header not set for ntlm');
2672 }
2673 $this->username = $username;
2674 $this->password = $password;
2675 $this->authtype = $authtype;
2676 $this->digestRequest = $digestRequest;
2677 }

References $authtype, $certRequest, $digest_uri, $digestRequest, $password, $username, nusoap_base\appendDebug(), nusoap_base\debug(), setHeader(), and nusoap_base\varDump().

Referenced by getResponse(), and setURL().

+ Here is the call graph for this function:
+ Here is the caller 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 @access private

Definition at line 2207 of file nusoap.php.

2208 {
2209 $this->debug("setCurlOption option=$option, value=");
2210 $this->appendDebug($this->varDump($value));
2211 curl_setopt($this->ch, $option, $value);
2212 }

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

Referenced by connect(), and sendRequest().

+ Here is the call graph for this function:
+ Here is the caller 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 @access public

Definition at line 2696 of file nusoap.php.

2697 {
2698 if (function_exists('gzdeflate')) {
2699 $this->protocol_version = '1.1';
2700 $this->setHeader('Accept-Encoding', $enc);
2701 if (!isset($this->outgoing_headers['Connection'])) {
2702 $this->setHeader('Connection', 'close');
2703 $this->persistentConnection = false;
2704 }
2705 #set_magic_quotes_runtime(0);
2706 // deprecated
2707 $this->encoding = $enc;
2708 }
2709 }

References setHeader().

+ Here is the call graph for this function:

◆ setHeader()

soap_transport_http::setHeader (   $name,
  $value 
)

sets an HTTP header

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

Definition at line 2221 of file nusoap.php.

2222 {
2223 $this->outgoing_headers[$name] = $value;
2224 $this->debug("set header $name: $value");
2225 }

References nusoap_base\debug().

Referenced by __construct(), buildPayload(), connect(), setContentType(), setCredentials(), setEncoding(), setProxy(), setSOAPAction(), setURL(), and usePersistentConnection().

+ Here is the call graph for this function:
+ Here is the caller 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) @access public

Definition at line 2721 of file nusoap.php.

2722 {
2723 if ($proxyhost) {
2724 $this->proxy = array(
2725 'host' => $proxyhost,
2726 'port' => $proxyport,
2727 'username' => $proxyusername,
2728 'password' => $proxypassword,
2729 'authtype' => $proxyauthtype
2730 );
2731 if ($proxyusername != '' && $proxypassword != '' && $proxyauthtype = 'basic') {
2732 $this->setHeader('Proxy-Authorization', ' Basic ' . base64_encode($proxyusername . ':' . $proxypassword));
2733 }
2734 } else {
2735 $this->debug('remove proxy');
2736 $proxy = null;
2737 unsetHeader('Proxy-Authorization');
2738 }
2739 }
unsetHeader($name)
unsets an HTTP header
Definition: nusoap.php:2233

References $proxy, nusoap_base\debug(), setHeader(), and unsetHeader().

+ Here is the call graph for this function:

◆ setSOAPAction()

soap_transport_http::setSOAPAction (   $soapaction)

set the soapaction value

Parameters
string$soapaction@access public

Definition at line 2685 of file nusoap.php.

2686 {
2687 $this->setHeader('SOAPAction', '"' . $soapaction . '"');
2688 }

References setHeader().

+ Here is the call graph for this function:

◆ setURL()

soap_transport_http::setURL (   $url)

sets the URL to which to connect

Parameters
string$urlThe URL to which to connect @access private

Definition at line 2247 of file nusoap.php.

2248 {
2249 $this->url = $url;
2250
2251 $u = parse_url($url);
2252 foreach ($u as $k => $v) {
2253 $this->debug("parsed URL $k = $v");
2254 $this->$k = $v;
2255 }
2256
2257 // add any GET params to path
2258 if (isset($u['query']) && $u['query'] != '') {
2259 $this->path .= '?' . $u['query'];
2260 }
2261
2262 // set default port
2263 if (!isset($u['port'])) {
2264 if ($u['scheme'] == 'https') {
2265 $this->port = 443;
2266 } else {
2267 $this->port = 80;
2268 }
2269 }
2270
2271 $this->uri = $this->path;
2272 $this->digest_uri = $this->uri;
2273
2274 // build headers
2275 if (!isset($u['port'])) {
2276 $this->setHeader('Host', $this->host);
2277 } else {
2278 $this->setHeader('Host', $this->host . ':' . $this->port);
2279 }
2280
2281 if (isset($u['user']) && $u['user'] != '') {
2282 $this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : '');
2283 }
2284 }

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

Referenced by __construct(), and getResponse().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unsetHeader()

soap_transport_http::unsetHeader (   $name)

unsets an HTTP header

Parameters
string$nameThe name of the header @access private

Definition at line 2233 of file nusoap.php.

2234 {
2235 if (isset($this->outgoing_headers[$name])) {
2236 $this->debug("unset header $name");
2237 unset($this->outgoing_headers[$name]);
2238 }
2239 }

References nusoap_base\debug().

Referenced by setProxy().

+ Here is the call graph for this function:
+ Here is the caller 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. @access public

Definition at line 3332 of file nusoap.php.

3333 {
3334 if (isset($this->outgoing_headers['Accept-Encoding'])) {
3335 return false;
3336 }
3337 $this->protocol_version = '1.1';
3338 $this->persistentConnection = true;
3339 $this->setHeader('Connection', 'Keep-Alive');
3340 return true;
3341 }

References setHeader().

+ Here is the call graph for this function:

Field Documentation

◆ $authtype

soap_transport_http::$authtype = ''

Definition at line 2166 of file nusoap.php.

Referenced by setCredentials().

◆ $certRequest

soap_transport_http::$certRequest = array()

Definition at line 2168 of file nusoap.php.

Referenced by setCredentials().

◆ $ch

soap_transport_http::$ch = false

Definition at line 2160 of file nusoap.php.

◆ $ch_options

soap_transport_http::$ch_options = array()

Definition at line 2161 of file nusoap.php.

◆ $digest_uri

soap_transport_http::$digest_uri = ''

Definition at line 2144 of file nusoap.php.

Referenced by setCredentials().

◆ $digestRequest

soap_transport_http::$digestRequest = array()

Definition at line 2167 of file nusoap.php.

Referenced by getResponse(), and setCredentials().

◆ $encoding

soap_transport_http::$encoding = ''

Definition at line 2151 of file nusoap.php.

◆ $fp

soap_transport_http::$fp

Definition at line 2140 of file nusoap.php.

◆ $host

soap_transport_http::$host = ''

Definition at line 2146 of file nusoap.php.

Referenced by connect().

◆ $incoming_cookies

soap_transport_http::$incoming_cookies = array()

Definition at line 2154 of file nusoap.php.

◆ $incoming_headers

soap_transport_http::$incoming_headers = array()

Definition at line 2153 of file nusoap.php.

◆ $incoming_payload

soap_transport_http::$incoming_payload = ''

Definition at line 2156 of file nusoap.php.

Referenced by getResponse().

◆ $outgoing_headers

soap_transport_http::$outgoing_headers = array()

Definition at line 2152 of file nusoap.php.

◆ $outgoing_payload

soap_transport_http::$outgoing_payload = ''

Definition at line 2155 of file nusoap.php.

◆ $password

soap_transport_http::$password = ''

Definition at line 2165 of file nusoap.php.

Referenced by setCredentials().

◆ $path

soap_transport_http::$path = ''

Definition at line 2148 of file nusoap.php.

Referenced by connect(), getCookiesForRequest(), parseCookie(), and setURL().

◆ $persistentConnection

soap_transport_http::$persistentConnection = false

Definition at line 2159 of file nusoap.php.

◆ $port

soap_transport_http::$port = ''

Definition at line 2147 of file nusoap.php.

Referenced by connect().

◆ $protocol_version

soap_transport_http::$protocol_version = '1.0'

Definition at line 2150 of file nusoap.php.

◆ $proxy

soap_transport_http::$proxy = null

Definition at line 2163 of file nusoap.php.

Referenced by setProxy().

◆ $request_method

soap_transport_http::$request_method = 'POST'

Definition at line 2149 of file nusoap.php.

◆ $response_status_line

soap_transport_http::$response_status_line

Definition at line 2157 of file nusoap.php.

◆ $scheme

soap_transport_http::$scheme = ''

Definition at line 2145 of file nusoap.php.

◆ $tryagain

soap_transport_http::$tryagain

Definition at line 2141 of file nusoap.php.

◆ $uri

soap_transport_http::$uri = ''

Definition at line 2143 of file nusoap.php.

Referenced by buildPayload(), and setURL().

◆ $url

soap_transport_http::$url = ''

Definition at line 2142 of file nusoap.php.

Referenced by __construct(), buildPayload(), connect(), and setURL().

◆ $use_curl

soap_transport_http::$use_curl = false

Definition at line 2162 of file nusoap.php.

Referenced by __construct().

◆ $username

soap_transport_http::$username = ''

Definition at line 2164 of file nusoap.php.

Referenced by setCredentials().

◆ $useSOAPAction

soap_transport_http::$useSOAPAction = true

Definition at line 2158 of file nusoap.php.


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