home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeCGI Programming with PerlSearch this book

2.4. Server Responses

Server responses, like client requests, always contain HTTP headers and an optional body. Here is the server response from our earlier example:

HTTP/1.1 200 OK
Date: Sat, 18 Mar 2000 20:35:35 GMT
Server: Apache/1.3.9 (Unix)
Last-Modified: Wed, 20 May 1998 14:59:42 GMT
ETag: "74916-656-3562efde"
Content-Length: 141
Content-Type: text/html

<HTML>
<HEAD><TITLE>Sample Document</TITLE></HEAD>
<BODY>
  <H1>Sample Document</H1>
  <P>This is a sample HTML document!</P>
</BODY>
</HTML>

The structure of the headers for the response is the same as for requests. The first header line has a special meaning, and is referred to as the status line. The remaining lines are name-value header field lines. See Figure 2-8.

Figure 2-8

Figure 2-8. The structure of an HTTP response header

2.4.2. Server Headers

After the status line, the server sends its HTTP headers. Some of these server headers are the same headers that browsers send with their requests. The common server headers are listed in Table 2-3.

Table 2-3. Common HTTP Server Headers

Header

Description

Content-Base

Specifies the base URL for resolving all relative URLs within the document

Content-Length

Specifies the length (in bytes) of the body

Content-Type

Specifies the media type of the body

Date

Specifies the date and time when the response was sent

ETag

Specifies an entity tag for the requested resource

Last-Modified

Specifies the date and time when the requested resource was last modified

Location

Specifies the new location for the resource

Server

Specifies the name and version of the web server

Set-Cookie

Specifies a name-value pair that the browser should provide with future requests

WWW-Authenticate

Specifies the authorization scheme and realm



Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.