Practical mod_perl / HTML Book /



previous page: 16.4.2. Conditional GET Requests
  
page up: HTML Version of the book
  
next page: 16.4.4. POST Requests

16.4.3. HEAD Requests


Among the headers described thus far, the date-related ones (Date, Last-Modified, and Expires/Cache-Control) are usually easy to produce and thus should be computed for HEAD requests just the same as for GET requests.

The Content-Type and Content-Length headers should be exactly the same as would be supplied to the corresponding GET request. But since it may be expensive to compute them, they can easily be omitted, since there is nothing in the specification that requires them to be sent.

What is important is that the response to a HEAD request must not contain a message-body. The code in a mod_perl handler might look like this:

# compute the headers that are easy to compute
# currently equivalent to $r->method eq "HEAD"
if ( $r->header_only ) { 
    $r->send_http_header;
    return OK;
}

If a Squid accelerator is being used, it will be able to handle the whole HEAD request by itself, but under some circumstances it may not be allowed to do so.

 

Continue to:

  • prev: 16.4.2. Conditional GET Requests
  • Table of Contents
  • next: 16.4.4. POST Requests







TOP
previous page: 16.4.2. Conditional GET Requests
  
page up: HTML Version of the book
  
next page: 16.4.4. POST Requests


Menu

  • HTML Book
  • PDF Book
  • Download Code
  • Table of Contents
  • Errata
  • mod_perl2 User's Guide
  • Sitemap

Search


Add to Google




Creative Commons License


Written by
Eric Cholet (Logilune) and
Stas Bekman (StasoSphere & Free Books).


[ Privacy Policy | Terms of Use | About Us | Search ]

© 2007 StasoSphere.com