Http message structure

Available

3.1 General view of the http message

Each http request (http request) has a specific structure. And the best thing is that it is a text file, quite readable even for an unprepared person.

The message consists of three parts. The first line is the so-called starting line , which determines the type of message. Then there are parameters, which are also called headers, headers . Well, at the very end is the body of the message .

And how to determine where the headers ended and the body of the message began? And here everything is simple: the headers and the body of the message are separated by an empty line . As soon as they saw an empty line in an http message, the message body immediately follows it.

3.2 Starting line

The type of the start line is standardized and is set by the template:

Method URI HTTP/Version

For a better understanding, let's take a few examples. CodeGym user's personal page is given by the linkhttps://codegym.cc/me

GET/me HTTP/1.0
Host: codegym.cc

As a response, the server will most likely send:

HTTP/1.0 200 OK
page text...

3.3 Headers

Headers are called headers because they come at the head of an http message. Perhaps it would be more correct to call them service parameters. They are needed so that the http client and http server understand better how to communicate and how exactly to interpret the received data.

Examples of such headers:

Content-Type: text/html;charset=windows-1251
Allow: GET,HEAD,OPTIONS
Content-Length: 1984

Each header is a name-value pair separated by a colon, just like in JSON. We will discuss them in more detail in the next lectures.

Comments
  • Popular
  • New
  • Old
You must be signed in to leave a comment
This page doesn't have any comments yet