PHP XMLHttpRequest Code _php Tutorial for implementing HTTP requests in ASP

Source: Internet
Author: User
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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.