On Fri, 4 Aug 2000, Vivek Khera wrote:
> >>>>> "NT" == Nathan Torkington <[EMAIL PROTECTED]> writes:
>
> NT> I see some programmers don't check header_only(). Are there
> NT> bad things in store if you don't? Or will Apache or the browser
> NT> simply ignore the body that gets created?
>
> My experience is apache just tosses the body for you. The programmer
> check is mainly an optimization from where I sit.
No, apache will send a body if you generate it even if the client just
sends a HEAD request. Example:
Head.pm:
========
package Head;
use strict;
use Apache::Constants 'OK';
sub handler {
my $r = shift; $r->content_type('text/plain'); $r->send_http_header;
print 'header_only() is ', ($r->header_only) ? "true\n" : "false\n";
return OK;
}
1;
httpd.conf:
===========
LoadModule mime_module libexec/mod_mime.so
ClearModuleList
AddModule mod_mime.c
AddModule mod_so.c
AddModule mod_perl.c
SetHandler perl-script
PerlHandler Head
$ telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
HEAD / HTTP/1.0
HTTP/1.1 200 OK
Date: Mon, 07 Aug 2000 17:17:47 GMT
Server: Apache/1.3.12 (Unix) mod_perl/1.24
Connection: close
Content-Type: text/plain
header_only() is true
Connection closed by foreign host.
$ telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET / HTTP/1.0
HTTP/1.1 200 OK
Date: Mon, 07 Aug 2000 17:17:52 GMT
Server: Apache/1.3.12 (Unix) mod_perl/1.24
Connection: close
Content-Type: text/plain
header_only() is false
Connection closed by foreign host.
A mod_proxy ProxyPass frontend will discard the body if given a "HEAD"
request though.