HTTP: The Definitive Guide
by David Gourley, Brian Totty, Marjorie Sayer, Anshu Aggarwal, Sailu Reddy
Messages
Now let’s take a quick look at the structure of HTTP request and response messages. We’ll study HTTP messages in exquisite detail in Chapter 3.
HTTP messages are simple, line-oriented sequences of characters. Because they are plain text, not binary, they are easy for humans to read and write.[1]Figure 1-7 shows the HTTP messages for a simple transaction.

Figure 1-7. HTTP messages have a simple, line-oriented text structure
HTTP messages sent from web clients to web servers are called request messages . Messages from servers to clients are called response messages . There are no other kinds of HTTP messages. The formats of HTTP request and response messages are very similar.
HTTP messages consist of three parts:
- Start line
The first line of the message is the start line, indicating what to do for a request or what happened for a response.
- Header fields
Zero or more header fields follow the start line. Each header field consists of a name and a value, separated by a colon (:) for easy parsing. The headers end with a blank line. Adding a header field is as easy as adding another line.
- Body
After the blank line is an optional message body containing any kind of data. Request bodies carry data to the web server; response bodies carry data back to the client. Unlike the start lines and headers, which are textual and structured, the body can contain arbitrary binary data (e.g., images, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access