1) HTTP Working Process
The HTTP protocol defines how the client requests data from the server and how the server transmits the data to the client , and the HTTP protocol uses the request/Response model C/S client Server.
The client sends a request message to the server that contains the requested method ,URL, protocol version , request Header , and request data .
The server responds with a status line that includes the version of the protocol, the reason phrase , the status code , the response header , and the response data .
This indicates the request/response model.
2) here are the steps for HTTP request/Response :
(1) client connects to Web server
An HTTP client, typically a browser (iOS app), establishes a connection to the Web server's HTTP port (default is 80) . For example, http://www.baicu.com.
(2) sending an HTTP request
Through the connection, the client sends a text request message to the Web server, and a request message consists of a request line , a request header , a blank line , and 4 parts of the requested data .
(3) The server accepts the request and returns the HTTP response
The Web server resolves the request and locates the requested resource. The server writes a copy of the resource to the connection, which is read by the client. A response consists of a status line , a response header , a blank line , and a 4 portion of the response data .
(4) release the connection
The Web server is actively disconnecting, and the client is passively connected .
(5) client browser parsing data
The client browser parses the status line first to see the status code indicating whether the request was successful.
each response header is then parsed , and the response header informs the following character sets for several bytes of HTML documents and documents.
The client browser reads the response data HTML, formats it according to the syntax of the HTML, and displays it in a browser window .
iOS Development Network Chapter--http Introduction