Network articles-application layer protocol-Http protocol

What is an agreement? An agreement is a regulation or a rule for the data format of the communicating parties. If you want to communicate with me, you must abide by this rule, otherwise I won't be able to identify what the data you send means. I will throw it away and leave it alone. [ If you like it a lot, I can share the implemented Http server code, even if it’s not too much, it’s two versions: libevent version, pure parsing protocol version ]

What does the Http protocol look like?

HTTP protocol isthe abbreviationof Hyper Text Transfer Protocol (Hyper Text Transfer Protocol), which is a transfer protocol used to transfer hypertext from a World Wide Web (WWW: World Wide Web) server to a local browser.

1. Request format: [Used by Client]

The request message that the client sends an HTTP request to the server includes the following format:

Request line

Request header

The blank line and the request data consist of four parts. The following figure shows the general format of the request message.

2. Server response

The HTTP response from the server to the client is also composed of four parts: status line, message header, blank line and response body.

 The response code and description that the server responds to the client

 

Response code

Code description

The requested content exists on the server and can respond to the client

 200

  OK

The client's request is abnormal and the method is faulty

501

Method Not Implemented

After the server received the request, it could not respond due to self-generated problems

500

Internal Server Error

The requested content does not exist

404

NOT FOUND

There is a problem with the request format sent by the client, etc.

400

BAD REQUEST

 

 

 

Guess you like

Origin blog.csdn.net/qq_44065088/article/details/109220997