|
Part:
1
2
3
4
5
6
7
This chapter describes:
- HTTP Response Syntax
- HTTP Response Header Lines
- Controlling Header Lines
- Viewing Header Lines
- Header Lines of Static Files
- Controlling Header Lines - Example Scripts
- Forcing the Browser to Redirect
- Generating Non-HTML Entity Body
- Sending Files for Downloading
HTTP Response Syntax
Based on HTTP/1.1 protocol, after receiving and interpreting an HTTP request
from a client, a server must responds with an HTTP response following the syntax
below:
status-line
header-line
...
header-line
entity-body
Note that:
- Response must have one status-line.
- Response can have zero, one, or many header lines.
- Response can only have zero or one entity-body.
- There is a blank line between header lines and the entity body.
- Status line, header line, and blank line must be ended with CRLF ("/r/n") characters.
- Entity body is the actual data requested by the client request.
- Header lines can be in any order.
Below is a simple HTTP response with two header lines:
HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 38
Hello world!
HTTP Response Header Lines
HTTP/1.1 response header lines allows the server to passes additional information
about the response which cannot be placed in the status line. Header lines can be
divided into three groups:
1. General header lines: Information about the transmission of the entire response
message:
Cache-Control
Connection
Date
Pragma
Trailer
Transfer-Encoding
Upgrade
Via
Warning
(Continued on next part...)
Part:
1
2
3
4
5
6
7
|