Recently I am doing the front end test summary series, interested friends can add attention, welcome to correct, exchange.

Strive for each knowledge point can sum up some more, at least to do in the interview, for each knowledge point can kan up, not dumb fire.

preface

We learned in our last article, “HTTP Overview,” that HTTP is an application-layer protocol that regulates client requests and server responses. Today, we’ll take a look at another important concept inside HTTP messages.

HTTP message

HTTP messages are the way data is exchanged between the server and the client.

classification

HTTP messages fall into two categories:

  • Client request messages — sent by clients to trigger an action on the server.
  • Server response messages — responses from the server.

Constitute a

A typical HTTP message consists of four parts:

  • Start Line – A start line describes the request to be executed, or the corresponding status, success or failure. The starting line is always a single line.
  • HTTP Headers — Represents a field used to convey additional information in an HTTP request or response, modifying or making more precise the semantics of the message (or the body of the message) being delivered.
  • Empty line — An empty line indicates that all metadata about the request has been sent.
  • Data body – An optional body containing data related to the request (such as HTML form content), or a document related to the response.

The composition of the request and response messages is roughly the same.

The HTTP header fields

HTTP Header fields are the parts of a message header in a hypertext Transfer Protocol (HTTP) request and response message.

They define the operational parameters of a HYPERtext Transfer protocol transaction.

HTTP header fields can be defined on their own, so non-standard header fields can be found on Web servers and browsers.

format

HTTP header fields are transmitted after a request or response line (the first line of a message).

The fields in the protocol header are as follows:

  • In plain text string format
  • Is a colon-delimited key-value pair
  • Ends with a carriage return (CR) plus line feed (LF) sequence
  • The end of the protocol header is identified by a blank field that transmits two consecutive CR + LF.

classification

HTTP header fields are classified into the following four types based on their actual use:

  • General Header Fields
  • Request Header Fields
  • Response Header Fields
  • Entity Header Fields (Response Header Fields)

The field values

Some fields can contain comment content (for example, in user-Agent, Server, and Via fields) that can be ignored by the application.

The values of many fields can contain key-value pairs with weights of quality (often referred to simply as Q) that are used during content negotiation.

Size limit

There are no restrictions on the name and value size of each protocol header field, nor on the number of fields.

However, for practical scenarios and security reasons, most servers, clients, and agents impose some restrictions.

For example, the Apache 2.3 server limits the size of each field to 8190 bytes by default, and a maximum of 100 header fields are allowed in a single request.

conclusion

HTTP messages are divided into request messages and response messages. The complete message consists of four parts.

HTTP headers fall into four categories.

~

Thanks for reading!

~

Learn interesting knowledge, meet interesting friends, shape interesting soul!

Hello everyone, I am the author of “programming Samadhi”, I am king Yi, my public account is “programming Samadhi”, welcome to pay attention, I hope you can give me more advice!

You come, with expectations, I have ink to welcome! You return, no matter gain or loss, only to yu Yun give each other!

Knowledge and skills should be paid equal attention to, internal force and external power should be repaired simultaneously, theory and practice should grasp both hands, both hands should be hard!