http protocol basics --- introduction, message format, status code

HTTP message format

2. URI sum URL

URI : The full name is a uniform resource identifier . It can be used to uniquely identify resources on the Internet. Usually, a compact string is used to indicate abstract or physical resources.
URI is composed of URL and URN

URL (Uniform Resource Locator) is a subset of URI , which is what we commonly call a web address . In addition to identifying a resource, it also provides a main access mechanism to locate the resource

Wikipedia:
URIs can be divided into URLs, URNs, or something with both locators and names.
URNs act like a person ’s name. URLs are like a person ’s address.
URNs determine the identity of something. URLs provide a way to find it

URL is a kind of URI , but not all URIs are URLs. The biggest difference between
URIs and URLs is the "access mechanism".
URN is a part of unique identification and is identity information.

·

3. HTTP request method

Common methods of HTTP / 1.1
1. GET
2. POST

3. PUT
4. HEAD

5. DELETE
6. OPTIONS

7. TRACE
8. CONNECT

GET to get resources

  1. The GET method is used to request access to the resource identified by the URI. The specified resource is parsed by the server and the response content is returned.
  2. The GET method can also be used to submit forms and other data but only a small amount of information can be transmitted, and the parameters will be displayed on the address bar, which is not safe

The POST
method is similar to the GET function.
The main purpose of the POST method is not to get the content of the response body.

PUT
The data transmitted from the client to the server replaces the content of the specified document. The
biggest difference between the PUT method and the POST method is: PUT is idempotent, and POST is not idempotent.
Therefore, we often use the PUT method as a transmission resources
POST adding data, update data PUT, PUT Since there is no authentication mechanism, do not use basic insecurity

HEAD is
similar to GET request, except that there is no specific content in the returned response, which is used to get the header

DELETE
requests the server to delete the specified resource. HTTP1.1 / has no authentication mechanism like PUT, and it is basically not used for insecurity

OPTIONS is
used to query the resource support method specified for the request URI

TRACE / CONNECT
TRACE:
Echo the request received by the server, mainly used for testing or diagnosis, which is easy to cause cross-site tracking

CONNECT:
Open a two-way communication channel between the client and the requested resource, create a tunnel for accessing the proxy server

4. HTTP status code

Status code: A 3-digit code used to indicate the response status of the web server hypertext transfer protocol
:
1xx indicates a message. This type of status code indicates that the request has been accepted and needs to continue processing. This type of response is a temporary response, only contains the status line and some optional response header information, and ends with a blank line

2xx means success. This type of status code indicates that the request has been successfully received, understood, and accepted by the server

3xx means redirect. This type of status code means that the client needs to take further action to complete the request. Generally, these status codes are used for redirection, and the subsequent request address (redirection target) is specified in the Location field of this response

4xx indicates a request error. This kind of status means that the client may seem to have an error, which hinders the server's processing. Unless the response is a head request, the server should return an entity that explains the current error condition and whether this is a temporary or permanent condition. Do these states apply to any request method. The browser should show the user any physical content contained in such an error response

5xx indicates a server error. This type of status code indicates that an error or abnormal state occurred during the processing of the request by the server. It may also be that the server realized that the current software and hardware resources could not complete the processing of the request. Unless this is a head request, the server should contain an information entity that explains the current error status and whether the situation is temporary or permanent. The browser should show the user any entities included in the current response

Common status code
200 ok The request was successful . The requested response header and data body are returned with the response.
202 accepted has been received , the request has been received, but the processing has not been completed
206 Partital Content part of the content , the server successfully processed part of the get request

301 Moved Permanently Move permanently , the requested resource has been permanently moved to the new URI, the returned information will include the new URI, and the browser will automatically be directed to the new URI. Any new requests in the future should use the new URI instead of
302 Found temporary movement , similar to 301. But resources are only temporarily moved. The client should continue to use the original URI

404 Bad Request client request syntax error, the server cannot understand the
401 Unauthorized request requires the user's identity authentication
403 Forbidden server understands the request client request, but refuses to execute the request
404 Not Found server cannot find resources based on the client request (web page)

500 internal Server Error server internal error, unable to complete the request
502 Bad Gateway acting as a gateway or proxy server, received an invalid request from the remote server

Published 21 original articles · Likes0 · Visits 163

Guess you like

Origin blog.csdn.net/qq_45227330/article/details/105019665