One, client and server:
The HTTP protocol is primarily used for communication between clients and servers.
1, client: request access to one end of the resource. (Know why C means the client?)
2, Server: Provides one end of a resource response.
Two computers communicating using the HTTP protocol, on one communication line, must have one end as the client and the other end as the server. As a matter of fact, between two computers as a server or client role may be interchangeable, in terms of a communication line (remember as if the channel, information Channels) client and server roles are fixed, and HTTP can clearly distinguish which is the client, That's the server.
Two, request and response:
Communication is reached between the client and the server through the exchange of requests and responses. (That's very good)
The HTTP protocol specifies that the request is made from the client and the last server-side response should be requested and returned. Therefore, the communication must first be started from the client, and the server will not send a response until the request is received.
(There is no thought of nsurlrequest,nsurlresponse)
1, Request message Format:
A, method: The following will detail
B,uri: Uniform Resource Locator
C, Request the Header field (header fields, intimate bar, many places will not tell you that is it):
Force insert
4 Types of header fields
- Universal Header Field (General header fields)
- Requested header field (Request header fields)
- Response Header field (Response header fields)
- Entity header field: header for the entity portion of the request message and Response message, supplementing the resource content update time with entity-related information
D, Entity content, data and parameters, etc.
2, the format of the response (Response):
A, protocol version
B, Status code: The following will be detailed; 2xx,3xx,4xx,5xx
C, reason phrase (reason-phrase): A simple description of the reason for success/failure
D, header fields: Some additional information about the response, date, content size, content format, and so on.
E, entities (entity body): The returned data, and so on.
HTTP Essentials Overview: Three, client and server, request and response