文档介绍:http协议详解(Detailed explanation of HTTP protocol)
The HTTP request consists of three parts:
Request line, message header, request text.
Request line (format):
Method Request-URI HTTP-Version CRLF
Method: method.
GET requests access to resources identified by Request-URI.
POST adds new data to the resource identified by Request-URI.
The HEAD request gets the response message header of the resource identified by the Request-URI.
The PUT request server stores a resource and uses Request-URI as its identifier.
The DELETE request server deletes the resources identified by the Request-URI.
TRACE requests the server to send back the requested information, the main language test or diagnosis.
CONNECT reserves future use.
OPTIONS requests to query the performance of the server, or to query the resource related options and requirements.
Request-URI: unified resource identifier.
HTTP-Version:HTTP version.
CRLF: return line feed. (\r\n)
Cases:
GET / HTTP/ \r\n
HTTP Response
After receiving and interpreting the request message, the server returns a HTTP response message.
Like the HTTP request, the HTTP response is posed of three parts:
Status line, message header, response body.
State line:
The state line is described by protocol version, status code in digital form, and the corresponding state description. Each element is separated by space.
Format: HTTP-Version Status-Code Reason-Phrase CRLF
For example: HTTP/ 200 OK \r\n
Status code:
The status code is made up of 3 digits to indicate whether the request is understood or satisfied.
State description:
The state description gives a short text description of the status code.
The first number of the status code defines the category of the response, and the latter two have no specific classification.
The first digit has five possible values:
- 1xx: indicates information - indicates that the request has been received and continues processing.
- 2xx: ess - indicates that the request has