Class Name: HttpRequest ($ url = "", $ method = "GET", $ useSocket = 0)
// $ Url indicates the request address. The default request method is GET. $ useSocket defaults to 0 and fsockopen is used. If it is set to 1, socket_create is used.
Method:
Open ($ ip = "", $ port =-1) // open the connection to the same server. By default, you do not need to set these two parameters (when a colleague is using linux, the requested IP address is not resolved by the hostname. Therefore, these two parameters are added to connect to the Real Server IP address)
SetTimeout ($ timeout = 0) // sets the time-out time for data retrieval. The value is valid only before the send method is called. The default value is 0, which is unlimited.
SetRequestHeader ($ key, $ value = "") // sets the request header, which must be set before the send method is called.
RemoveRequestHeader ($ key, $ value = "") // removes the request header with the specified key value, which must be called before the send method is called.
Send ($ data = "") // send $ data to the server
GetResponseBody () // get the text returned by the server
GetAllResponseHeaders () // get all the header information of the server response
GetResponseHeader ($ key) // obtain a header of the Server response, such as Server and Set_Cookie.
Attribute:
$ Url // the url to be requested
$ Method // Request method (POST/GET)
$ Port // request port
$ Hostname // The requested Host Name
$ Uri // The file part of the url
$ Protocol // request protocol (http) (more than five attributes including this attribute are automatically analyzed by the program through url)
$ Excption // exception information
$ _ Headers = array () // Request Header array ("key" => "value ")
$ _ Senddata // data sent to the server
$ Status // returned status code
$ StatusText // status information
$ HttpProtocolVersion // HTTP Protocol version of the server
Note:
The Host header is automatically set by the program. When a POST request is used, Content-Length and Content-Type are automatically set.
Pages that support gzip Compression
Php_XmlHttpRequest.rar