Home  >  Article  >  Web Front-end  >  HTTP protocol knowledge closely related to front-end development

HTTP protocol knowledge closely related to front-end development

little bottle
little bottleforward
2019-04-16 09:07:192820browse

What front-end engineers deal with most is the browser. No matter what they do, they cannot do without the browser. Among them, the HTTP protocol is often It will be ignored by us, but in fact, resource caching, CDN loading, page performance optimization, etc. are all inseparable from the understanding of the HTTP protocol.

HTTP is also called Hypertext Transfer Protocol, full name: Hyper Transfer Protocol. Initially HTTP could only transmit HTML files, but now it can transmit text, images, videos and various streaming files.

HTTP is stateless: the same client initiates multiple requests in succession. To the HTTP server, they are all new requests. HTTP has no way of knowing that it comes from a client.

HTTP message structure: To see the specific message structure, you need to use a packet capture tool, so here is only a brief introduction without specific examples. The message structures of request and response are basically the same.

Header: divided into request/response line and request/response header.

request/response line: includes the request method (GET/POST), the path to resource and the version number of the http protocol.

request/response header: Here are the various request headers.

Body: Response body, usually an HTML file. If it is a get request, there is no response body.

HTTP request method:

GET Request to obtain the resource identified by Request-URI
POST Append new data after the resource identified by Request-URI
HEAD Request to obtain by The response message header of the resource identified by Request-URI
PUT Requests the server to store a resource and uses Request-URI as its identifier
DELETE Requests the server to delete the resource identified by Request-URI
TRACE Requests the server to send back a receipt The requested request information is mainly used for testing or diagnosis
CONNECT is reserved for future use
OPTIONS requests to query the performance of the server, or query options and requirements related to resources

For us, commonly used That is GET, and POST. Let me reiterate, there is no need to submit a form, and there is no security issue with get compared to post.

HTTP status code:

1XX Prompt message - Indicates that the request has been successfully received and continues to be processed.

2XX Success - Indicates that the request has been successfully received, understood, and accepted

3XX Redirect - Further processing must be performed to complete the request

4XX Client Error - Request There is a syntax error or the request cannot be implemented

5XX Server-side error - The server cannot implement a legal request

There are many status codes, you can understand them by yourself, I think there are a few that you must know.

HTTP communication process: query DNS according to URL, find server, establish TCP connection, send request, and server response.

For HTTP, I think the basics are to know that HTTP is stateless, HTTP message structure, basic request method, and basic status code.

There is still a lot to learn about the HTTP protocol, this is just the basic need to know.

Welcome to follow Coding’s personal notes public account

##What front-end engineers deal with most is the browser, no matter what they do Inseparable from the browser, the HTTP protocol is often ignored by us, but in fact, resource caching, CDN loading, page performance optimization, etc. are all inseparable from the understanding of the HTTP protocol.

HTTP is also called Hypertext Transfer Protocol, full name: Hyper Transfer Protocol. Initially HTTP could only transmit HTML files, but now it can transmit text, images, videos and various streaming files.

HTTP is stateless: the same client initiates multiple requests in succession. To the HTTP server, they are all new requests. HTTP has no way of knowing that it comes from a client.

HTTP message structure: To see the specific message structure, you need to use a packet capture tool, so here is only a brief introduction without specific examples. The message structures of request and response are basically the same.

Header: divided into request/response line and request/response header.

request/response line: includes the request method (GET/POST), the path to resource and the version number of the http protocol.

request/response header: Here are the various request headers.

Body: Response body, usually an HTML file. If it is a get request, there is no response body.

HTTP request method:

GET Request to obtain the resource identified by Request-URI
POST Append new data after the resource identified by Request-URI
HEAD Request to obtain the response message header of the resource identified by Request-URI
PUT Requests the server to store a resource and uses Request-URI as its identifier
DELETE Requests the server to delete the resource identified by Request-URI
TRACE Requests the server to send back the received request information, mainly used for testing or diagnosis
CONNECT is reserved for future use of
OPTIONS requests to query the server's performance, or to query resource-related options and requirements

For us, the commonly used ones are GET, and POST. Let me reiterate, there is no need to submit a form, and there is no security issue with get compared to post.

HTTP status code:

1XX Prompt message - Indicates that the request has been successfully received and continues to be processed.

2XX Success - Indicates that the request has been successfully received, understood, and accepted

3XX Redirect - Further processing must be performed to complete the request

4XX Client Error - Request There is a syntax error or the request cannot be implemented

5XX Server-side error - The server cannot implement a legal request

There are many status codes, you can understand them by yourself, I think there are a few that you must know.

HTTP communication process: query DNS according to URL, find server, establish TCP connection, send request, and server response.

For HTTP, I think the basics are to know that HTTP is stateless, HTTP message structure, basic request method, and basic status code.

There is still a lot to learn about the HTTP protocol, this is just the basic need to know.

[Recommended course: HTTP video course]

The above is the detailed content of HTTP protocol knowledge closely related to front-end development. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete