Lines Matching refs:this

62 		$this->debug("ctor url=$url use_curl=$use_curl curl_options:");
63 $this->appendDebug($this->varDump($curl_options));
64 $this->setURL($url);
66 $this->ch_options = $curl_options;
68 $this->use_curl = $use_curl;
69 ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev);
70 $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
81 $this->debug("setCurlOption option=$option, value=");
82 $this->appendDebug($this->varDump($value));
83 curl_setopt($this->ch, $option, $value);
94 $this->outgoing_headers[$name] = $value;
95 $this->debug("set header $name: $value");
105 if (isset($this->outgoing_headers[$name])) {
106 $this->debug("unset header $name");
107 unset($this->outgoing_headers[$name]);
118 $this->url = $url;
122 $this->debug("parsed URL $k = $v");
123 $this->$k = $v;
128 $this->path .= '?' . $u['query'];
134 $this->port = 443;
136 $this->port = 80;
140 $this->uri = $this->path;
141 $this->digest_uri = $this->uri;
145 $this->setHeader('Host', $this->host);
147 $this->setHeader('Host', $this->host.':'.$this->port);
151 $this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : '');
162this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'nt…
164 …if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array…
190 …$this->debug("connect connection_timeout $connection_timeout, response_timeout $response_timeout, …
191 if ($this->io_method() == 'socket') {
192 if (!is_array($this->proxy)) {
193 $host = $this->host;
194 $port = $this->port;
196 $host = $this->proxy['host'];
197 $port = $this->proxy['port'];
201 if($this->persistentConnection && isset($this->fp) && is_resource($this->fp)){
202 if (!feof($this->fp)) {
203 $this->debug('Re-use persistent connection');
206 fclose($this->fp);
207 $this->debug('Closed persistent connection at EOF');
211 if ($this->scheme == 'ssl') {
214 …$this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout…
218 $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str, $connection_timeout);
220 $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str);
224 if(!$this->fp) {
225 $msg = 'Couldn\'t open socket connection to server ' . $this->url;
226 if ($this->errno) {
227 $msg .= ', Error ('.$this->errno.'): '.$this->error_str;
231 $this->debug($msg);
232 $this->setError($msg);
237 $this->debug('set response timeout to ' . $response_timeout);
238 socket_set_timeout( $this->fp, $response_timeout);
240 $this->debug('socket connected');
242 } else if ($this->io_method() == 'curl') {
245 …$this->setError('The PHP cURL Extension is required for HTTPS or NLTM. You will need to re-build …
274 $this->debug('connect using cURL');
276 $this->ch = curl_init();
278 …$hostURL = ($this->port != '') ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$thi…
280 $hostURL .= $this->path;
281 $this->setCurlOption(CURLOPT_URL, $hostURL);
284 $this->debug('safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION');
285 $this->debug('safe_mode = ');
286 $this->appendDebug($this->varDump(ini_get('safe_mode')));
287 $this->debug('open_basedir = ');
288 $this->appendDebug($this->varDump(ini_get('open_basedir')));
290 $this->setCurlOption(CURLOPT_FOLLOWLOCATION, 1);
293 $this->setCurlOption(CURLOPT_HEADER, 1);
295 $this->setCurlOption(CURLOPT_RETURNTRANSFER, 1);
302 if ($this->persistentConnection) {
308 $this->persistentConnection = false;
309 $this->setHeader('Connection', 'close');
313 $this->setCurlOption($CURLOPT_CONNECTIONTIMEOUT, $connection_timeout);
316 $this->setCurlOption(CURLOPT_TIMEOUT, $response_timeout);
319 if ($this->scheme == 'https') {
320 $this->debug('set cURL SSL verify options');
325 $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
326 $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0);
329 if ($this->authtype == 'certificate') {
330 $this->debug('set cURL certificate options');
331 if (isset($this->certRequest['cainfofile'])) {
332 $this->setCurlOption(CURLOPT_CAINFO, $this->certRequest['cainfofile']);
334 if (isset($this->certRequest['verifypeer'])) {
335 $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, $this->certRequest['verifypeer']);
337 $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 1);
339 if (isset($this->certRequest['verifyhost'])) {
340 $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, $this->certRequest['verifyhost']);
342 $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1);
344 if (isset($this->certRequest['sslcertfile'])) {
345 $this->setCurlOption(CURLOPT_SSLCERT, $this->certRequest['sslcertfile']);
347 if (isset($this->certRequest['sslkeyfile'])) {
348 $this->setCurlOption(CURLOPT_SSLKEY, $this->certRequest['sslkeyfile']);
350 if (isset($this->certRequest['passphrase'])) {
351 $this->setCurlOption(CURLOPT_SSLKEYPASSWD, $this->certRequest['passphrase']);
353 if (isset($this->certRequest['certpassword'])) {
354 $this->setCurlOption(CURLOPT_SSLCERTPASSWD, $this->certRequest['certpassword']);
358 if ($this->authtype && ($this->authtype != 'certificate')) {
359 if ($this->username) {
360 $this->debug('set cURL username/password');
361 $this->setCurlOption(CURLOPT_USERPWD, "$this->username:$this->password");
363 if ($this->authtype == 'basic') {
364 $this->debug('set cURL for Basic authentication');
365 $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_BASIC);
367 if ($this->authtype == 'digest') {
368 $this->debug('set cURL for digest authentication');
369 $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_DIGEST);
371 if ($this->authtype == 'ntlm') {
372 $this->debug('set cURL for NTLM authentication');
373 $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_NTLM);
376 if (is_array($this->proxy)) {
377 $this->debug('set cURL proxy options');
378 if ($this->proxy['port'] != '') {
379 $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host'].':'.$this->proxy['port']);
381 $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host']);
383 if ($this->proxy['username'] || $this->proxy['password']) {
384 $this->debug('set cURL proxy authentication options');
385 … $this->setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy['username'].':'.$this->proxy['password']);
386 if ($this->proxy['authtype'] == 'basic') {
387 $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_BASIC);
389 if ($this->proxy['authtype'] == 'ntlm') {
390 $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_NTLM);
394 $this->debug('cURL connection set up');
397 $this->setError('Unknown scheme ' . $this->scheme);
398 $this->debug('Unknown scheme ' . $this->scheme);
415 $this->debug('entered send() with data of length: '.strlen($data));
417 $this->tryagain = true;
419 while ($this->tryagain) {
420 $this->tryagain = false;
423 if (!$this->connect($timeout, $response_timeout)){
428 if (!$this->sendRequest($data, $cookies)){
433 $respdata = $this->getResponse();
435 $this->setError("Too many tries to get an OK response ($this->response_status_line)");
438 $this->debug('end of send()');
455 return $this->send($data, $timeout, $response_timeout, $cookies);
469 $this->debug("setCredentials username=$username authtype=$authtype digestRequest=");
470 $this->appendDebug($this->varDump($digestRequest));
471 $this->debug("certRequest=");
472 $this->appendDebug($this->varDump($certRequest));
475 …$this->setHeader('Authorization', 'Basic '.base64_encode(str_replace(':','',$username).':'.$passwo…
489 $A2 = $this->request_method . ':' . $this->digest_uri;
521 …$this->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . $digestRequest[…
524 $this->certRequest = $certRequest;
525 $this->debug('Authorization header not set for certificate');
528 $this->debug('Authorization header not set for ntlm');
530 $this->username = $username;
531 $this->password = $password;
532 $this->authtype = $authtype;
533 $this->digestRequest = $digestRequest;
543 $this->setHeader('SOAPAction', '"' . $soapaction . '"');
554 $this->protocol_version = '1.1';
555 $this->setHeader('Accept-Encoding', $enc);
556 if (!isset($this->outgoing_headers['Connection'])) {
557 $this->setHeader('Connection', 'close');
558 $this->persistentConnection = false;
562 $this->encoding = $enc;
578 $this->proxy = array(
586 …$this->setHeader('Proxy-Authorization', ' Basic '.base64_encode($proxyusername.':'.$proxypassword)…
589 $this->debug('remove proxy');
640 $this->debug('no linebreak found in decodeChunked');
648 $this->debug("chunkstart: $chunkstart chunk_size: $chunk_size");
694 $this->setHeader('Content-Length', strlen($data));
697 if ($this->proxy) {
698 $uri = $this->url;
700 $uri = $this->uri;
702 $req = "$this->request_method $uri HTTP/$this->protocol_version";
703 $this->debug("HTTP request: $req");
704 $this->outgoing_payload = "$req\r\n";
707 foreach($this->outgoing_headers as $k => $v){
709 $this->debug("HTTP header: $hdr");
710 $this->outgoing_payload .= "$hdr\r\n";
716 $this->debug("HTTP header: $hdr");
717 $this->outgoing_payload .= "$hdr\r\n";
721 $this->outgoing_payload .= "\r\n";
724 $this->outgoing_payload .= $data;
737 …$cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme ==…
740 $this->buildPayload($data, $cookie_str);
742 if ($this->io_method() == 'socket') {
744 if(!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
745 $this->setError('couldn\'t write message data to socket');
746 $this->debug('couldn\'t write message data to socket');
749 $this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
751 } else if ($this->io_method() == 'curl') {
758 foreach($this->outgoing_headers as $k => $v){
760 $this->debug("Skip cURL header $k: $v");
768 $this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers);
769 $this->debug('set cURL HTTP headers');
770 if ($this->request_method == "POST") {
771 $this->setCurlOption(CURLOPT_POST, 1);
772 $this->setCurlOption(CURLOPT_POSTFIELDS, $data);
773 $this->debug('set cURL POST data');
777 foreach ($this->ch_options as $key => $val) {
778 $this->setCurlOption($key, $val);
781 $this->debug('set cURL payload');
793 $this->incoming_payload = '';
795 if ($this->io_method() == 'socket') {
801 if(feof($this->fp)) {
802 $this->incoming_payload = $data;
803 $this->debug('found no headers before EOF after length ' . strlen($data));
804 $this->debug("received before EOF:\n" . $data);
805 $this->setError('server failed to send headers');
809 $tmp = fgets($this->fp, 256);
811 $this->debug("read line of $tmplen bytes: " . trim($tmp));
814 $this->incoming_payload = $data;
815 $this->debug('socket read of headers timed out after length ' . strlen($data));
816 $this->debug("read before timeout: " . $data);
817 $this->setError('socket read of headers timed out');
838 $this->incoming_payload .= $data;
839 $this->debug('found end of headers after length ' . strlen($data));
843 $this->incoming_headers = array();
844 $this->incoming_cookies = array();
849 $this->incoming_headers[$header_name] = trim($arr[1]);
852 $cookie = $this->parseCookie(trim($arr[1]));
854 $this->incoming_cookies[] = $cookie;
855 $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
857 $this->debug('did not find cookie in ' . trim($arr[1]));
862 $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
867 …if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['tra…
870 $this->debug("want to read chunked content");
871 } elseif (isset($this->incoming_headers['content-length'])) {
872 $content_length = $this->incoming_headers['content-length'];
874 $this->debug("want to read content of length $content_length");
878 $this->debug("want to read content to EOF");
883 $tmp = fgets($this->fp, 256);
885 $this->debug("read chunk line of $tmplen bytes");
887 $this->incoming_payload = $data;
888 $this->debug('socket read of chunk length timed out after length ' . strlen($data));
889 $this->debug("read before timeout:\n" . $data);
890 $this->setError('socket read of chunk length timed out');
894 $this->debug("chunk length $content_length");
897 while (($strlen < $content_length) && (!feof($this->fp))) {
899 $tmp = fread($this->fp, $readlen);
901 $this->debug("read buffer of $tmplen bytes");
902 if (($tmplen == 0) && (!feof($this->fp))) {
903 $this->incoming_payload = $data;
904 $this->debug('socket read of body timed out after length ' . strlen($data));
905 $this->debug("read before timeout:\n" . $data);
906 $this->setError('socket read of body timed out');
913 $tmp = fgets($this->fp, 256);
915 $this->debug("read chunk terminator of $tmplen bytes");
917 $this->incoming_payload = $data;
918 $this->debug('socket read of chunk terminator timed out after length ' . strlen($data));
919 $this->debug("read before timeout:\n" . $data);
920 $this->setError('socket read of chunk terminator timed out');
924 } while ($chunked && ($content_length > 0) && (!feof($this->fp)));
925 if (feof($this->fp)) {
926 $this->debug('read to EOF');
928 $this->debug('read body of length ' . strlen($data));
929 $this->incoming_payload .= $data;
930 $this->debug('received a total of '.strlen($this->incoming_payload).' bytes of data from server');
934 …(isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection'])…
935 (! $this->persistentConnection) || feof($this->fp)){
936 fclose($this->fp);
937 $this->fp = false;
938 $this->debug('closed socket');
942 if($this->incoming_payload == ''){
943 $this->setError('no response from server');
958 } else if ($this->io_method() == 'curl') {
960 $this->debug('send and receive with cURL');
961 $this->incoming_payload = curl_exec($this->ch);
962 $data = $this->incoming_payload;
964 $cErr = curl_error($this->ch);
966 $err = 'cURL ERROR: '.curl_errno($this->ch).': '.$cErr.'<br>';
968 foreach(curl_getinfo($this->ch) as $k => $v){
971 $this->debug($err);
972 $this->setError($err);
973 curl_close($this->ch);
981 $this->debug('No cURL error, closing cURL');
982 curl_close($this->ch);
986 while ($this->isSkippableCurlHeader($data)) {
987 $this->debug("Found HTTP header to skip");
1013 $this->debug('no proper separation of headers and document');
1014 $this->setError('no proper separation of headers and document');
1020 $this->debug('found proper separation of headers and document');
1021 $this->debug('cleaned data, stringlen: '.strlen($data));
1027 $this->incoming_headers[$header_name] = trim($arr[1]);
1030 $cookie = $this->parseCookie(trim($arr[1]));
1032 $this->incoming_cookies[] = $cookie;
1033 $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
1035 $this->debug('did not find cookie in ' . trim($arr[1]));
1040 $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
1045 $this->response_status_line = $header_array[0];
1046 $arr = explode(' ', $this->response_status_line, 3);
1052 if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
1053 …$this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']…
1054 $this->setURL($this->incoming_headers['location']);
1055 $this->tryagain = true;
1060 if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
1061 …$this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authent…
1062 if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
1063 $this->debug('Server wants digest authentication');
1065 $digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']);
1076 $this->setCredentials($this->username, $this->password, 'digest', $digestRequest);
1077 $this->tryagain = true;
1081 $this->debug('HTTP authentication failed');
1082 $this->setError('HTTP authentication failed');
1091 …$this->setError("Unsupported HTTP response status $http_status $http_reason (soapclient->response …
1096 …if(isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding…
1097 …if(strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incom…
1103 $this->debug('The gzinflate function exists');
1105 if ($this->incoming_headers['content-encoding'] == 'deflate') {
1108 $this->debug('The payload has been inflated to ' . strlen($data) . ' bytes');
1111 $this->debug('The inflated payload is smaller than the gzipped one; try again');
1114 $this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes');
1118 $this->debug('Error using gzinflate to inflate the payload');
1119 $this->setError('Error using gzinflate to inflate the payload');
1121 } elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
1124 $this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes');
1127 $this->debug('The un-gzipped payload is smaller than the gzipped one; try again');
1130 $this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes');
1134 $this->debug('Error using gzinflate to un-gzip the payload');
1135 $this->setError('Error using gzinflate to un-gzip the payload');
1141 $this->incoming_payload = $header_data.$lb.$lb.$data;
1143 …$this->debug('The server sent compressed data. Your php install must have the Zlib extension compi…
1144 …$this->setError('The server sent compressed data. Your php install must have the Zlib extension co…
1147 $this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
1148 $this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
1151 $this->debug('No Content-Encoding header');
1155 $this->debug('no data after headers!');
1156 $this->setError('no data present after HTTP headers');
1171 $this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : ''));
1181 if (isset($this->outgoing_headers['Accept-Encoding'])) {
1184 $this->protocol_version = '1.1';
1185 $this->persistentConnection = true;
1186 $this->setHeader('Connection', 'Keep-Alive');
1271 $this->debug("check cookie for validity: ".$cookie['name'].'='.$cookie['value']);
1274 $this->debug('cookie has expired');
1280 if (! preg_match("'.*$domain$'i", $this->host)) {
1281 $this->debug('cookie has different domain');
1287 if (! preg_match("'^$path.*'i", $this->path)) {
1288 $this->debug('cookie is for a different path');
1293 $this->debug('cookie is secure, transport is not');
1297 $this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);