[Front-end basics] HTTP protocol

The interview wave has subsided a bit recently. I took advantage of the residual heat to catch a wave and record the interview-related questions accompanied by the collected information. I have no intention of knowing and learning more (doubt) ^_^

I like two screens, while writing a blog and checking information

The first wave: HTTP protocol Hyper Text Transfer Protocol (Hyper Text Transfer Protocol) application layer protocol
from World Wide Web (WWW: World Wide Web) server to transfer hypertext to the local browser transfer protocol
TCP/IP communication protocol to transfer data (HTML files, image files, query results, etc.)
Features: simple and fast, flexible, connectionless, stateless

URI: uniform resource identifier: Uniform resource identifier , which identifies a resource and
      consists of the naming mechanism for accessing the resource, the host name where the resource is stored, and the resource name (represented by a path, with emphasis on the resource)

URL: Uniform Resource Identifiers Uniform Resource Locator
Consists of protocol, host ip address (port number), and specific address of host resource (directory, file name) It
identifies a resource and indicates how to load this resource, and identifies the address of a resource: transmission data, connection

https://blog.csdn.net/qq_31382921/article/details/52678183
https://blog.csdn.net/ma15732625261/article/details/79821160
HTTPS协议
blog.csdn.net域名,端口号不是必须,HTTP默认的端口号为80,HTTPS的端口号为443
qq_31**21 虚拟目录:域名后第一个/ 到最后一个/ 不是必须
文件名:最后一个/ 到? ,没有? 则到# 
锚:从?到# 参数、搜索查询用

URN: uniform resource name Uniform resource naming , identifying resources by name

Request request:

      Format: request line request line header header, blank line and request data, as follows
request

  • Request line: The HTTP version used by the resource to be accessed by the request type
  • Request header: used to describe additional information to be used by the server

method:

HTTP 1.0 defines three request methods: GET, POST and HEAD methods.

HTTP1.1 added five new request methods: OPTIONS, PUT, DELETE, TRACE and CONNECT methods.

method describe
GET Request the specified page information and return the entity body.
HEAD Similar to the get request, except that there is no specific content in the returned response, and the header can be obtained
POST Submit data to a specified resource for processing requests (such as submitting a form or uploading a file)
data is included in the request body;
use POST to create resources when the resource identifier URI is not known;
cause the creation of new resources and the modification of old resources; usually non-cached The method of the request
state is not uniform, it is "safe" to do any processing in the POST request
PUT The data sent from the client to the server replaces the contents of the specified document;
to use PUT PUT is idempotent when allowing the client to specify the resource identifier URI of the newly created resource
, you must send all possible values ​​to ensure idempotency;
(To use a PUT request you have to send all accessible properties/values, not just the ones you want to change)
DELETE Requests the server to delete the specified page.
CONNECT The HTTP/1.1 protocol is reserved for proxy servers that can change connections to pipes.
The server acts as a springboard, allowing the server to visit other web pages on behalf of the user, and then return the data to the user in its original form.
OPTIONS Allows clients to view server performance HTTP request methods supported by the
server for a specific resource
TRACE Echo the request received by the server, mainly for testing or diagnostics.

The difference between GET and POST There is a lot of information on the Internet. It is safer to simply write a post and transmit a large amount of data.

State Unity:

For executing the same http request multiple times, the status of the resource processing server is the same. GET/HEAD/PUT/DELETE all have this feature, POST does not.

Corresponding Response

Response
Source rookie tutorial

状态行:由HTTP协议版本号, 状态码, 状态消息 三部分组成
    (HTTP/1.1)表明HTTP版本为1.1版本,状态码为200,状态消息为(ok)
消息报头:说明客户端需要使用的一些附加信息,上面是服务器端
    Date:生成响应的日期和时间;Content-Type:指定了MIME类型的HTML(text/html),编码类型是UTF-8
空行,消息报头后面的空行是必须的
响应正文,服务器返回给客户端的文本信息

status code

Tutorial for Rookies: Three Digits

  • 1xx: Indication Information – Indicates that the request has been received, continue processing
  • 2xx: Success – Indicates that the request was successfully received, understood, accepted
  • 3xx: Redirect – further action must be taken to complete the request
  • 4xx: Client Error – The request has a syntax error or the request cannot be fulfilled
  • 5xx: Server Side Error – The server failed to fulfill a legitimate request

How HTTP works:

The HTTP protocol defines how a web client requests a web page from a web server, and how the server transmits the web page to the client;

step:

The client sends a request message to the server, and the request message contains the requested method, URL, protocol version, request header and request data.

The server responds with a status line containing the protocol version, success or error code, server information, response headers, and response data.

                                                                                        - request/response model

Have you found that the HTTP/1.1 header fields are repeated and verbose: it is easy to cause delays in TCP connections

Improve:

     2.0 Interleaves establishment requests and corresponding messages on the same connection, uses efficient encoding of HTTP header fields, allows for priority of requests, enables more requests to complete quickly, improves performance, and relatively reduces TCP connections: it is more efficient than other streams. Less competition for longer connections and more efficient use of network capacity;

HTTP2.0

I heard that HTTP 2.0 has come out. Baidu checked a lot of information, and there are so many things to learn
. Let’s talk about HTTP 2.0 briefly, to catch up with the trend

  • Multiplexing, HEAD compression, server push, priority requests

Overview:

1. The basic protocol unit is the frame. Each frame has different types and uses
        . Header HEADERS and data DATA frames form HTTP requests and responses.

2. Request multiplexing distributes multiple HTTP request-response exchanges on a stream (independent of each other)

3. Flow control and priority ensure the correct use of multiplexed streams, and flow control helps ensure that only the data used by the recipient is propagated

4. New interactive mode, the server can push messages to the client: the server predicts the client's needs

5. The HTTP header fields contained in the frame are compressed

document structure

Part Four:
Starting HTTP/2: How the connection
     initiates the application layer protocol initiated by the client and running on the TCP connection
Frame and Stream Layer: Describe the structure of HTTP/2 streams and how to form multiplexed streams
Frame and Error Codes: Definition Details of Streams and Error Types Used in HTTP/2
HTTP Addressing, Extended Requirements: How HTTP Semantics Are Expressed by Frames and Streams

See HTTP 2.0 Chinese version for details

Summary:
This is the note from last Sunday at 08:34:58 on April 19, 2018. After the
exam, I felt liberated and happy ( ^▽^ )

Thanks for the following sharing:

Idempotency: Encyclopedia
HTTP protocol detailed explanation for
rookie tutorial HTTP protocol
pseudo: The difference between using put and post in
HTTP protocol About HTTP protocol, one article is enough
HTTP proxy protocol HTTP/1.1 CONNECT method
Thank you for sharing, respect the original work, from the link start

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325563983&siteId=291194637