HTTP: Request Messages
HTTP request messages are a pivotal part of the protocol. Let's take a close look at them!
Introduction
There are two types of HTTP messages, as discussed previously:
- HTTP request messages
- HTTP response messages
We’ll study request messages in this lesson.
HTTP request messages
Let’s look at request messages first. Here is an example of a typical HTTP request message:
Press + to interact
GET /path/to/file/index.html HTTP/1.1Host: www.educative.ioConnection: closeUser-agent: Mozilla/5.0Accept-language: frAccept: text/html
It should be noted that:
- HTTP messages are in plain ASCII text.
- Each line of the message ends with two control characters: a carriage return and a line feed:
\r\n
.- The last line of the message also ends with a carriage return and a line feed!
- This particular message has six lines, but HTTP messages can have one to as many lines as needed.
- The first line is called the request line, while the rest are called header lines.
The anatomy of an HTTP request line
An HTTP request line is followed by an HTTP header. We’ll look at the request line first. The request line consists of three parts:
- Method
- URL
- Version