var $connected_port = -1;
var $connected_ssl = 0;
+ private $content_length_set;
+
/* Private methods - DO NOT CALL */
- Function Tokenize($string,$separator="")
+ private function Tokenize($string,$separator="")
{
if(!strcmp($separator,""))
{
}
}
- Function CookieEncode($value, $name)
+ private function CookieEncode($value, $name)
{
return($name ? str_replace("=", "%25", $value) : str_replace(";", "%3B", $value));
}
- Function SetError($error, $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR)
+ private function SetError($error, $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR)
{
$this->error_code = $error_code;
return($this->error=$error);
}
- Function SetPHPError($error, &$php_error_message, $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR)
+ private function SetPHPError($error, &$php_error_message, $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR)
{
if(IsSet($php_error_message)
&& strlen($php_error_message))
return($this->SetError($error, $error_code));
}
- Function SetDataAccessError($error,$check_connection=0)
+ private function SetDataAccessError($error,$check_connection=0)
{
$this->error=$error;
$this->error_code = HTTP_CLIENT_ERROR_COMMUNICATION_FAILURE;
}
}
- Function OutputDebug($message)
+ private function OutputDebug($message)
{
if($this->log_debug)
error_log($message);
}
}
- Function GetLine()
+ private function GetLine()
{
for($line="";;)
{
}
}
- Function PutLine($line)
+ private function PutLine($line)
{
if($this->debug)
$this->OutputDebug("C $line");
return(1);
}
- Function PutData($data)
+ private function PutData($data)
{
if(strlen($data))
{
return(1);
}
- Function FlushData()
+ private function FlushData()
{
if(!fflush($this->connection))
{
return(1);
}
- Function ReadChunkSize()
+ private function ReadChunkSize()
{
if($this->remaining_chunk==0)
{
return("");
}
- Function ReadBytes($length)
+ private function ReadBytes($length)
{
if($this->use_curl)
{
return($bytes);
}
- Function EndOfInput()
+ private function EndOfInput()
{
if($this->use_curl)
return($this->read_response>=strlen($this->response));
return(feof($this->connection));
}
- Function Resolve($domain, &$ip, $server_type)
+ private function Resolve($domain, &$ip, $server_type)
{
if(preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/',$domain))
$ip=$domain;
return('');
}
- Function Connect($host_name, $host_port, $ssl, $server_type = 'HTTP')
+ private function Connect($host_name, $host_port, $ssl, $server_type = 'HTTP')
{
$domain=$host_name;
$port = $host_port;
}
}
- Function Disconnect()
+ private function Disconnect()
{
if($this->debug)
$this->OutputDebug("Disconnected from ".$this->connected_host);
/* Public methods */
- Function GetRequestArguments($url, &$arguments)
+ public function GetRequestArguments($url, &$arguments)
{
$this->error = '';
$this->error_code = HTTP_CLIENT_ERROR_NO_ERROR;
return("");
}
- Function Open($arguments)
+ public function Open($arguments)
{
if(strlen($this->error))
return($this->error);
return("");
}
- Function Close($force = 0)
+ public function Close($force = 0)
{
if($this->state=="Disconnected")
return("1 already disconnected");
return($this->Disconnect());
}
- Function PickCookies(&$cookies,$secure)
+ private function PickCookies(&$cookies,$secure)
{
if(IsSet($this->cookies[$secure]))
{
}
}
- Function GetFileDefinition($file, &$definition)
+ private function GetFileDefinition($file, &$definition)
{
$name="";
if(IsSet($file["FileName"]))
if(GetType($length=@filesize($file["FileName"]))!="integer")
{
$error="it was not possible to determine the length of the file ".$file["FileName"];
- if(IsSet($php_errormsg)
- && strlen($php_errormsg))
- $error.=": ".$php_errormsg;
if(!file_exists($file["FileName"]))
$error="it was not possible to access the file ".$file["FileName"];
return($error);
return("");
}
- Function ConnectFromProxy($arguments, &$headers)
+ private function ConnectFromProxy($arguments, &$headers)
{
if(!$this->PutLine('CONNECT '.$this->host_name.':'.($this->host_port ? $this->host_port : 443).' HTTP/1.0')
|| (strlen($this->user_agent)
return("");
}
- Function SendRequest($arguments)
+ public function SendRequest($arguments)
{
if(strlen($this->error))
return($this->error);
return("");
}
- Function SetCookie($name, $value, $expires="" , $path="/" , $domain="" , $secure=0, $verbatim=0)
+ private function SetCookie($name, $value, $expires="" , $path="/" , $domain="" , $secure=0, $verbatim=0)
{
if(strlen($this->error))
return($this->error);
return("");
}
- Function SendRequestBody($data, $end_of_data)
+ private function SendRequestBody($data, $end_of_data)
{
if(strlen($this->error))
return($this->error);
return("");
}
- Function ReadReplyHeadersResponse(&$headers)
+ private function ReadReplyHeadersResponse(&$headers)
{
$headers=array();
if(strlen($this->error))
return("");
}
- Function Redirect(&$headers)
+ private function Redirect(&$headers)
{
if($this->follow_redirect)
{
return("");
}
- Function Authenticate(&$headers, $proxy, &$proxy_authorization, &$user, &$password, &$realm, &$workstation)
+ private function Authenticate(&$headers, $proxy, &$proxy_authorization, &$user, &$password, &$realm, &$workstation)
{
if($proxy)
{
if(IsSet($headers[$authenticate_header])
&& $this->sasl_authenticate)
{
- if(function_exists("class_exists")
- && !class_exists("sasl_client_class"))
+ if(!class_exists('sasl_client_class'))
+ {
return($this->SetError("the SASL client class needs to be loaded to be able to authenticate".($proxy ? " with the proxy server" : "")." and access this site", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
+ }
if(GetType($headers[$authenticate_header])=="array")
$authenticate=$headers[$authenticate_header];
else
else
$mechanisms[]=$mechanism;
}
- $sasl=new sasl_client_class;
+ $sasl=new \sasl_client_class();
if(IsSet($user))
$sasl->SetCredential("user",$user);
if(IsSet($password))
$sasl->SetCredential("uri",$this->request_uri);
$sasl->SetCredential("method",$this->request_method);
$sasl->SetCredential("session",$this->session);
+ $message = '';
+ $interactions = [];
do
{
$status=$sasl->Start($mechanisms,$message,$interactions);
}
return("");
}
-
- Function ReadReplyHeaders(&$headers)
+
+ public function ReadReplyHeaders(&$headers)
{
if(strlen($error=$this->ReadReplyHeadersResponse($headers)))
return($error);
return("");
}
- Function ReadReplyBody(&$body,$length)
+ private function ReadReplyBody(&$body,$length)
{
$body="";
if(strlen($this->error))
return("");
}
- Function ReadWholeReplyBody(&$body)
+ public function ReadWholeReplyBody(&$body)
{
$body = '';
for(;;)
}
}
- Function SaveCookies(&$cookies, $domain='', $secure_only=0, $persistent_only=0)
+ private function SaveCookies(&$cookies, $domain='', $secure_only=0, $persistent_only=0)
{
$now=gmdate("Y-m-d H-i-s");
$cookies=array();
}
}
- Function SavePersistentCookies(&$cookies, $domain='', $secure_only=0)
+ private function SavePersistentCookies(&$cookies, $domain='', $secure_only=0)
{
$this->SaveCookies($cookies, $domain, $secure_only, 1);
}
- Function GetPersistentCookies(&$cookies, $domain='', $secure_only=0)
+ private function GetPersistentCookies(&$cookies, $domain='', $secure_only=0)
{
$this->SavePersistentCookies($cookies, $domain, $secure_only);
}
- Function RestoreCookies($cookies, $clear=1)
+ private function RestoreCookies($cookies, $clear=1)
{
$new_cookies=($clear ? array() : $this->cookies);
for($secure_cookies=0, Reset($cookies); $secure_cookies<count($cookies); Next($cookies), $secure_cookies++)