Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to quickly sort out the HTTP system

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "how to quickly sort out the HTTP system". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

HTTP defines HTTP (Hypertext transfer Protocol) as a bridge for information exchange between the client and the server. What must be done before information exchange is that the client connects to port 80 of the TCP/IP protocol so that the server can listen for HTTP requests. 3.HTTP is a general purpose, stateless application layer protocol based on the standard client / server model. Characteristics of HTTP

1. Using the "request / response" interaction mode, the client sends the request, the server accepts the request, processes the request, and returns the processing result to the client. The server will not actively send the request.

two。 The design of the protocol is flexible and expandable. HTTP can achieve new functions by extending new request methods.

3. Stateless: the protocol has no storage capability for transactions, which means that if the result of the last response is needed in the request, it cannot be used.

Disadvantages:

The number of connections increases at a time.

Advantages:

1. The server has high processing speed and high efficiency.

two。 The overhead of state synchronization between cluster features is avoided.

4. Persistent connection: the connection can be reused, which improves the efficiency of network connection. Persistent connections are already the default option in HTTP1.1. 5. Support content negotiation

HTTP request / response interaction model HTTP common request method GET method

The 1.GET method is used by the client to obtain resources from the server. The resource types include picture, audio, HTML.

two。 When the server processes the GET request, it will return the result according to the specific parameters on the url sent by the client.

3. When using GET request to obtain a large amount of data, the transmission process may be interrupted. HTTP protocol provides a breakpoint continuation mechanism, and you can specify the starting point when obtaining resources through the GET method.

POST method

The 1.POST method is mainly for the client to send data resources to the server.

The difference between the 2.POST and GET methods: the POST request contains the information body, which carries the data to be sent to the server.

HEAD method HEAD method is similar to GET method POST method

The difference is:

The request URL returned by the GET method identifies the resource content itself

The HEAD method only returns the relevant response header information, not the resource content.

The 3.HEAD method is mainly used to test whether the resource exists and whether the PUT method is deleted or modified.

The PUT method replaces all current representations of the target resource with the request payload.

DELETE

The DELETE method deletes the specified resource.

HTTP URIURI

1. The definition of URI, through a resource marker (Uniform Resource Identifier, URI), means that every available resource on the web, such as HTML documents, images, video clips, programs, etc., is located by a URI. The structure of 2.URI is as follows:

Naming mechanism for ① to access resources

② hostname where resources are stored

The name of the ③ resource itself.

3. Instance https://xxx.xxx.com/details/1 ① this is a resource that can be accessed through the https protocol

② is located on the host xxx.xxx.com

③ can uniquely identify the resource through "/ details/1" (note that this is not necessarily a complete path)

URI constitutes URL uniform resource locator unified resource name URL

1. Define URL as a subset of URI. It is the abbreviation of Uniform Resource Locator, translated as "uniform resource locator".

The general format of 2.URL is (bracketed [] is optional): protocol: / / hostname [: port] / path / [; parameters] [? query] # fragment

The format of 3.URL consists of three parts: the first part of ① is the protocol (or service mode).

The second part of the ② is the IP address (and sometimes the port number) of the host where the resource is stored.

The third part of the ③ is the specific address of the host resource, such as directory and file name.

The first part and the second part are separated by the symbol ": / /".

The second part and the third part are separated by a "/" symbol.

The first part and the second part are indispensable, and the third part can sometimes be omitted.

The difference between URL and URI

URI: unified Resource Identifier (Uniform Resource Identifier) URL: unified Resource Locator (uniform resource location) to put it bluntly, both URI and URL locate the location of the resource, indicating the location information of the resource, just like latitude and longitude, which corner of the world you are in. URI is a broader definition, while URL is a subset of URI, meaning that URL is part of URI. In other words, every URL is URI, but not every URI is URL.

HTTP sends request

HTTP response request

HTTP status code

100 Continue continues. The client should continue its request

101Switching Protocols switching protocol. The server switches the protocol according to the request of the client. You can only switch to a more advanced protocol, for example, to a new version of HTTP

200 OK request succeeded. Commonly used for GET and POST requests

201 Created has been created. Successfully requested and created a new resource

202 Accepted accepted. The request has been accepted but the processing has not been completed

203 Non-Authoritative Information unauthorized information. The request was successful. But the returned meta information is not on the original server, but on a copy.

204 No Content has no content. The server successfully processed but did not return content. If the web page is not updated, ensure that the browser continues to display the current document

205 Reset Content resets the content. The server is processed successfully, and the user terminal (for example, browser) should reset the document view. The form field of the browser can be cleared by this return code

206part of Partial Content. The server successfully processed some GET requests

300 Multiple Choices multiple options. The requested resource may include multiple locations, which can return a list of resource characteristics and addresses for user terminal (e. G. browser) selection

301 Moved Permanently permanent move. The requested resource has been permanently moved to the new URI, the returned information will include the new URI, and the browser will be automatically directed to the new URI. Any new requests in the future should be replaced by a new URI

302 Found temporary movement. Similar to 301. But resources are only temporarily moved. The client should continue to use the original URI

303 See Other look at other addresses. Similar to 301. Use GET and POST to request view

304Not Modified has not been modified. The requested resource has not been modified, and when the server returns this status code, no resource will be returned. The client usually caches the accessed resources, indicating that the client wants to return only those resources that have been modified after the specified date by providing a header information

305 Use Proxy uses proxies. The requested resource must be accessed through an agent

306 Unused obsolete HTTP status code

307 Temporary Redirect temporary redirection. Similar to 302. Request redirection using GET

The syntax error of 400 Bad Request client request is too bad for the server to understand

401 Unauthorized request requires user's identity authentication

402 Payment Required reserved for future use

The Forbidden server understands the request of the requesting client, but refuses to execute the request

The Not Found server cannot find the resource (web page) according to the client's request. Through this code, the website designer can set up a personality page that the resource you requested cannot be found.

Methods in 405 Method Not Allowed client requests are prohibited

The 406 Not Acceptable server cannot complete the request according to the content characteristics of the client request

The 407 Proxy Authentication Required request requires the authentication of the agent, similar to 401, but the requester should use the agent for authorization

The 408 Request Time-out server waited too long for the request sent by the client, and timed out

This code may be returned when the 409 Conflict server completes the client's PUT request, and there is a conflict when the server processes the request

The resource requested by the 410 Gone client no longer exists. 410 is different from 404, if the resource has been permanently deleted and the 410 code can be used, the website designer can specify the new location of the source through the 301 code.

411 the Length Required server cannot process the request information sent by the client without Content-Length

412 precondition error for Precondition Failed client request information

413 Request Entity Too Large rejected the request because the requested entity was too large for the server to process. To prevent continuous requests from the client, the server may close the connection. If only the server cannot process it temporarily, it will contain a Retry-After response message.

414 the URI of the Request-URI Too Large request is too long (the URI is usually the URL) and the server cannot process it.

415 the Unsupported Media Type server cannot process the media format that comes with the request

Invalid scope requested by 416 Requested range not satisfiable client

417 Expectation Failed server cannot satisfy the request header information of Expect

422 Conflict indicates that the create or modify operation cannot be completed because the data provided as part of the request is illegal

429 TooManyRequests indicates that the client access frequency limit has been exceeded or the server has received more requests than it can handle. It is recommended that the client read the appropriate Retry-After header, and then wait for the time indicated by the header to try again.

500 Internal Server Error server internal error, unable to complete the request

501 Not Implemented server does not support the requested function and cannot complete the request

502 Bad Gateway received an invalid response from the remote server when trying to execute the request as a gateway or agent

503 Service Unavailable due to overload or system maintenance, the server is temporarily unable to process client requests. The length of the delay can be included in the server's Retry-After header information

Gateway Time-out acts as a gateway or proxy server and fails to obtain requests from remote servers in a timely manner

The requested version of the HTTP protocol is not supported by the 505 HTTP Version not supported server

HTTP status code classification

1 request *-- > message. The server receives a request and requires the requestor to continue execution.

2successfully *-- > the operation was received and processed successfully

3 redirect *-- > redirect, further operation is required to complete the request

4 error *-> client side error, request contains syntax error or cannot complete the request

5 error *-- > server error occurred while processing the request

This is the end of the egg link "how to quickly sort out the HTTP system". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report