Hypertext Transfer Protocol, HTTP request process

Source: Internet
Author: User

Hypertext Transfer Protocol . 2.http Request procedure .

{

1> HTTP protocol : Hypertext Transfer Protocol (hypertext Transfer Protocol)

{

The HTTP protocol specifies the format of data transfer between the client and the server .

The HTTP protocol is the most commonly used protocol in web development . access to network resources often uses the HTTP protocol , Whether it is a mobile client or a PC-side.

HTTP Advantages :

<1> simple and fast :

HTTP protocol is simple and communication speed is very fast .

<2> flexibility :

the HTTP protocol allows the transfer of any type of data .

<3> HTTP protocol is a short connection ( non-persistent connection )

The HTTP protocol restricts each connection to only one request , and disconnects immediately after the server responds to the client's request . This way, the transmission time can be saved .

}

2> use of HTTP protocol ;

Complete http communication is divided into two steps :

<1> request : the client requests data from the server .

{

the HTTP protocol stipulates that a complete http request contains ' request line ',' request header ',' Three parts of the request body;

' request line ': contains the request method , request resource Path , HTTP protocol version .

"get/resources/images/http/1.1"

' request header ': contains information such as the client's environment description , the host address requested by the client .

The type of data that the accept:text/html//client can receive

ACCEPT-LANGUAGE:ZH-CN // Client language environment

Accept-encoding:gzip // client-supported data compression formats

host:m.baidu.com // the server host address that the client wants to access

user-agent:mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:37.0) gecko/20100101 firefox/37.0 // client type , Software Environment for c14> clients

' request body ': specific data that the client sends to the server, such as files / images .

}

<2> response : The server returns the data the client wants .

{

the HTTP protocol states that a complete http response contains a ' status line ',' response header ',' entity content ' ' three parts ;

' status line ': contains the HTTP protocol version , status , status English name .

"http/1.1 OK"

' response header ': contains a description of the server and a description of the returned data .

Content-encoding:gzip // server supported data compression format

Content-length: 1528 // length of returned data

content-type:application/xhtml+xml;charset=utf-8 // type of return data

Date:mon, June: £ º GMT // response time

Server:apache // server type

' entity content ': specific data returned by the server to the client ( image /html/ file ... ).

}

3> send http request :

{

in IOS development , there are a number of scenarios for sending HTTP requests, often in the following ways :

<1> Apple Native :

{

* Nsurlconnection: simple to use, a scheme of ancient classics .

* Nsurlsession:ios7 technology , features more powerful than nsurlconnection .

* the bottom of the Cfnetwork:nsurl , pure C language , generally not .

}

<2> Third-Party framework :

{

* Asihttprequest:http Terminator , the function is very powerful , Unfortunately the author has stopped updating .

* Afnetworking: simple to use, provides basic enough common functions , Maintenance and users more .

* Mknetworkkit: easy to use, produced from India , less maintenance and users .

}

in development , third-party frameworks are generally used .

}

}

Hypertext Transfer Protocol, HTTP request process

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.