Lines Matching refs:this

79         $this->agent        = 'Mozilla/4.0 (compatible; DokuWiki HTTP Client; '.PHP_OS.')';
80 $this->timeout = 15;
81 $this->cookies = array();
82 $this->referer = '';
83 $this->max_redirect = 3;
84 $this->redirect_count = 0;
85 $this->status = 0;
86 $this->headers = array();
87 $this->http = '1.0';
88 $this->debug = false;
89 $this->max_bodysize = 0;
90 $this->header_regexp= '';
91 if(extension_loaded('zlib')) $this->headers['Accept-encoding'] = 'gzip';
92 $this->headers['Accept'] = 'text/xml,application/xml,application/xhtml+xml,'.
94 $this->headers['Accept-Language'] = 'en-us';
110 if(!$this->sendRequest($url)) return false;
111 if($this->status == 304 && $sloppy304) return $this->resp_body;
112 if($this->status < 200 || $this->status > 206) return false;
113 return $this->resp_body;
137 $url .= $this->_postEncode($data);
138 return $this->get($url,$sloppy304);
152 if(!$this->sendRequest($url,$data,'POST')) return false;
153 if($this->status < 200 || $this->status > 206) return false;
154 return $this->resp_body;
175 $this->start = $this->_time();
176 $this->error = '';
177 $this->status = 0;
178 $this->status = 0;
179 $this->resp_body = '';
180 $this->resp_headers = array();
183 if($this->max_bodysize &&
184 !$this->max_bodysize_abort &&
185 $this->headers['Accept-encoding'] == 'gzip'){
186 unset($this->headers['Accept-encoding']);
196 if(isset($uri['user'])) $this->user = $uri['user'];
197 if(isset($uri['pass'])) $this->pass = $uri['pass'];
200 …if($this->proxy_host && (!$this->proxy_except || !preg_match('/'.$this->proxy_except.'/i',$url)) ){
202 $server = $this->proxy_host;
203 $port = $this->proxy_port;
205 $use_tls = $this->proxy_ssl;
215 $this->status = -200;
216 $this->error = 'This PHP version does not support SSL - cannot connect to server';
222 $headers = $this->headers;
225 $headers['User-Agent'] = $this->agent;
226 $headers['Referer'] = $this->referer;
235 $headers['Content-Type'] = 'multipart/form-data; boundary=' . $this->boundary;
236 $data = $this->_postMultipartEncode($data);
240 $data = $this->_postEncode($data);
252 if($this->user) {
253 $headers['Authorization'] = 'Basic '.base64_encode($this->user.':'.$this->pass);
255 if($this->proxy_user) {
256 … $headers['Proxy-Authorization'] = 'Basic '.base64_encode($this->proxy_user.':'.$this->proxy_pass);
260 $connectionId = $this->_uniqueConnectionId($server,$port);
261 $this->_debug('connection pool', self::$connections);
264 $this->_debug('reusing connection', $connectionId);
268 $this->_debug('opening connection', $connectionId);
270 $socket = @fsockopen($server,$port,$errno, $errstr, $this->timeout);
272 $this->status = -100;
273 $this->error = "Could not connect to $server:$port\n$errstr ($errno)";
279 if($this->_ssltunnel($socket, $request_url)){
281 $this->keep_alive = false;
286 $this->status = $e->getCode();
287 $this->error = $e->getMessage();
293 if ($this->keep_alive) {
300 if ($this->keep_alive && !$this->proxy_host) {
314 $request = "$method $request_url HTTP/".$this->http.HTTP_NL;
315 $request .= $this->_buildHeaders($headers);
316 $request .= $this->_getCookies();
320 $this->_debug('request',$request);
321 $this->_sendData($socket, $request, 'request');
326 $r_line = $this->_readLine($socket, 'headers');
330 $this->_debug('response headers',$r_headers);
333 … if($this->max_bodysize && preg_match('/\r?\nContent-Length:\s*(\d+)\r?\n/i',$r_headers,$match)){
334 if($match[1] > $this->max_bodysize){
335 if ($this->max_bodysize_abort)
338 $this->error = 'Reported content length exceeds allowed response size';
346 $this->status = $m[2];
349 $this->resp_headers = $this->_parseHeaders($r_headers);
350 if(isset($this->resp_headers['set-cookie'])){
351 foreach ((array) $this->resp_headers['set-cookie'] as $cookie){
356 if(isset($this->cookies[$key])){
357 unset($this->cookies[$key]);
360 $this->cookies[$key] = $val;
365 $this->_debug('Object headers',$this->resp_headers);
368 if($this->status == 301 || $this->status == 302 ){
369 if (empty($this->resp_headers['location'])){
371 }elseif($this->redirect_count == $this->max_redirect){
379 $this->redirect_count++;
380 $this->referer = $url;
382 if (!preg_match('/^http/i', $this->resp_headers['location'])){
383 if($this->resp_headers['location'][0] != '/'){
384 … $this->resp_headers['location'] = $uri['scheme'].'://'.$uri['host'].':'.$uri['port'].
385 … dirname($uri['path']).'/'.$this->resp_headers['location'];
387 … $this->resp_headers['location'] = $uri['scheme'].'://'.$uri['host'].':'.$uri['port'].
388 $this->resp_headers['location'];
392 return $this->sendRequest($this->resp_headers['location'],array(),'GET');
397 if($this->header_regexp && !preg_match($this->header_regexp,$r_headers))
402 …if((isset($this->resp_headers['transfer-encoding']) && $this->resp_headers['transfer-encoding'] ==…
403 …|| (isset($this->resp_headers['transfer-coding']) && $this->resp_headers['transfer-coding'] == 'ch…
407 … while (preg_match('/^[a-zA-Z0-9]?$/',$byte=$this->_readData($socket,1,'chunk'))){
413 $this->_readLine($socket, 'chunk'); // readtrailing \n
416 if($this->max_bodysize && $chunk_size+strlen($r_body) > $this->max_bodysize){
417 if ($this->max_bodysize_abort)
419 $this->error = 'Allowed response size exceeded';
420 $chunk_size = $this->max_bodysize - strlen($r_body);
425 $r_body .= $this->_readData($socket, $chunk_size, 'chunk');
426 $this->_readData($socket, 2, 'chunk'); // read trailing \r\n
429 …}elseif(isset($this->resp_headers['content-length']) && !isset($this->resp_headers['transfer-encod…
437 …if(!$this->keep_alive && $this->max_bodysize && $this->max_bodysize < $this->resp_headers['content…
438 $length = $this->max_bodysize;
440 $length = $this->resp_headers['content-length'];
443 … $r_body = $this->_readData($socket, $length, 'response (content-length limited)', true);
444 …}elseif( !isset($this->resp_headers['transfer-encoding']) && $this->max_bodysize && !$this->keep_a…
445 …$r_body = $this->_readData($socket, $this->max_bodysize, 'response (content-length limited)', true…
446 } elseif ((int)$this->status === 204) {
451 $r_body .= $this->_readData($socket, 4096, 'response (unlimited)', true);
456 if($this->max_bodysize){
457 if(strlen($r_body) > $this->max_bodysize){
458 if ($this->max_bodysize_abort) {
461 $this->error = 'Allowed response size exceeded';
467 $this->error = $err->getMessage();
469 $this->status = $err->getCode();
475 if (!$this->keep_alive ||
476 … (isset($this->resp_headers['connection']) && $this->resp_headers['connection'] == 'Close')) {
483 if(isset($this->resp_headers['content-encoding']) &&
484 $this->resp_headers['content-encoding'] == 'gzip' &&
486 $this->resp_body = @gzinflate(substr($r_body, 10));
487 if($this->resp_body === false){
488 $this->error = 'Failed to decompress gzip encoded content';
489 $this->resp_body = $r_body;
492 $this->resp_body = $r_body;
495 $this->_debug('response body',$this->resp_body);
496 $this->redirect_count = 0;
511 if(!$this->proxy_host) return false;
519 if($this->proxy_user) {
520 …$request .= 'Proxy-Authorization: Basic '.base64_encode($this->proxy_user.':'.$this->proxy_pass).H…
524 $this->_debug('SSL Tunnel CONNECT',$request);
525 $this->_sendData($socket, $request, 'SSL Tunnel CONNECT');
530 $r_line = $this->_readLine($socket, 'headers');
534 $this->_debug('SSL Tunnel Response',$r_headers);
576 $time_used = $this->_time() - $this->start;
577 if($time_used > $this->timeout)
621 $time_used = $this->_time() - $this->start;
622 if ($time_used > $this->timeout)
668 $time_used = $this->_time() - $this->start;
669 if ($time_used > $this->timeout)
702 if(!$this->debug) return;
704 $this->_debug_text($info, $var);
706 $this->_debug_html($info, $var);
717 print '<b>'.$info.'</b> '.($this->_time() - $this->start).'s<br />';
734 print '*'.$info.'* '.($this->_time() - $this->start)."s\n";
808 foreach ($this->cookies as $key => $val){
838 $boundary = '--'.$this->boundary;
893 $this->proxy_host = $conf['proxy']['host'];
894 $this->proxy_port = $conf['proxy']['port'];
895 $this->proxy_user = $conf['proxy']['user'];
896 $this->proxy_pass = conf_decodeString($conf['proxy']['pass']);
897 $this->proxy_ssl = $conf['proxy']['ssl'];
898 $this->proxy_except = $conf['proxy']['except'];
909 $this->debug = true;