1. http request
Basic HTTP request format
========================================================== ==============
<Request line> request line
<Headers> Request Header (parameter header)
<Blank line> blank line
[<Request-body>] Request Entity (get does not have Post)
==============================================
1.1 request line:
Located in the first line of the Request Message
Format: Request Method resource path HTTP Version Number <CRLF press ENTER line feed space tab>
Common Request Methods: Get and post
Difference between get and post:
(1) on the client side, the get method submits data through the URL, and the data can be seen in the URL. In the post mode, the data is placed in the HTML header for submission.
(2) a maximum of 1 K data can be submitted in get mode, but not in post mode.
(3) security issues. When get is used, the parameters are displayed in the address bar, which is not secure, whereas post is not displayed, which is safe. If the data is Chinese and non-sensitive, use get. If the data you enter is not Chinese characters and contains sensitive data, use post as well.
(4) idempotence
1.2 parameter header: starting from the second line to the first empty line. Purpose: Send some basic information about the client to the server.
Ii. Http response
Basic HTTP Response format
========================================================== ==============
<Status line> Status line
<Headers> Response Header
[<Request-body>] response entity
==============================================
The only real difference is that the request line is replaced by the Status line in the first row. Status line describes the requested resources by providing a status code.
Status Code |
Description |
100 ~ 199 |
The request is successfully received, and the client is required to submit the next request to complete the entire process. |
200 ~ 299 |
Indicates that the request is successfully received and the entire process has been completed. |
300 ~ 399 |
To complete the request, the customer needs to further refine the request. For example, the requested resource has moved a new address. |
400 ~ 499 |
Client request Error |
500 ~ 599 |
Server errors |
Common status codes:
200 (normal): indicates that everything is normal, and the returned result is a normal request.
302/307 (temporary redirection): indicates that the requested document has been temporarily moved elsewhere. The new URL of this document is provided in the location response header.
304 (not modified): indicates that the Client Cache version is the latest, and the client can continue to use it without sending requests to the server.
404 (not found): no resources requested by the client exist on the server.
500 (internal server error): A program error occurs on the server.