Class Name: HttpRequest ($url = "", $method = "GET", $useSocket =0)
The $url is the requested address; The default request method is GET, $useSocket defaults to 0, the Fsockopen method is used, and the Socket_create method is used if set to 1
Method:
Open ($ip = "", $port =-1)//Opens the connection with the server, the default does not set these two parameters (a colleague in Linux, the request is not hostname resolved IP, so add the two parameters to connect the real server IP)
SetTimeout ($timeout =0)//Set time-out to get data, must be set before the Send method call is valid, in seconds, the default value of 0 is unlimited
setRequestHeader ($key, $value = "")//Set the request header, which must be set before the Send method call is valid
Removerequestheader ($key, $value = "")//Remove the request header for the specified key value, which must be called before the Send method call is valid
Send ($data = "")//Transmit data $data to server
Getresponsebody ()//Get the text returned by the server
getAllResponseHeaders ()//Get all header information for server response
getResponseHeader ($key)//Get header information for server response, such as Server,set_cookie
Property:
$url//URL to request
$method//Request method (Post/get)
$port//Requested Port
$hostname//Host name of the request
$uri part of the//url file
$protocol//Request Protocol (HTTP) (including the 5 properties above are automatically parsed by the program via URL)
$excption//Exception information
$_headers=array ()//Request header Array ("Key" = "value")
$_senddata//data sent to the server
$status//Return status code
$statusText//status information
$HttpProtocolVersion//HTTP protocol version of the server
Attention:
The host header is set automatically by the program, and Content-length and Content-type are set automatically when the Post method is requested.
Pages that support gzip compression
Php_xmlhttprequest.rar
http://www.bkjia.com/PHPjc/323012.html www.bkjia.com true http://www.bkjia.com/PHPjc/323012.html techarticle class Name: HttpRequest ($url = "", $method = "Get", $useSocket =0)//$url as the requested address; The default request method is GET; $useSocket default is 0, using the Fsockopen method, If set to 1 then use ...