HTTP Message Flow and Message Parts - Part 1 of Chapter 3 from HTTP: The Definitive Guide (2/7)
[previous] [next] |
HTTP: The Definitive Guide, Chapter 3: HTTP Messages
The Parts of a Message
HTTP messages are simple, formatted blocks of data. Take a peek at Figure 3-3 for an example. Each message contains either a request from a client or a response from a server. They consist of three parts: a start line describing the message, a block of headers containing attributes, and an optional body containing data.
Figure 3-3. Three parts of an HTTP message
The start line and headers are just ASCII text, broken up by lines. Each line ends with a two-character end-of-line sequence, consisting of a carriage return (ASCII 13) and a line-feed character (ASCII 10). This end-of-line sequence is written "CRLF." It is worth pointing out that while the HTTP specification for terminating lines is CRLF, robust applications also should accept just a line-feed character. Some older or broken HTTP applications do not always send both the carriage return and line feed.
The entity body or message body (or just plain "body") is simply an optional chunk of data. Unlike the start line and headers, the body can contain text or binary data or can be empty.
In the example in Figure 3-3, the headers give you a bit of information about the body. The Content-Type line tells you what the body is--in this example, it is a plain-text document. The Content-Length line tells you how big the body is; here it is a meager 19 bytes.
[previous] [next] |
Created: January 13, 2003
Revised: January 13, 2003
URL: https://webreference.com/programming/http/chap3/1/2.html