hi all...
ok, I've had the chance to look at t/apache/content_length_header.t and I
_think_ I understand what the issues are.
it all seems to come back to this change:
http://cvs.apache.org/viewcvs.cgi/httpd-2.0/server/protocol.c?r1=1.150&r2=1.151
it looks as though this single change affected 2.1 in that GET and HEAD
requests can now be expected to behave exactly the same wrt the C-L header.
at least this is what our tests show - in 2.1 there is no difference at all
between the C-L header that GET and HEAD produce. overall a good thing, I'd
think.
the only thing that makes me uneasy is that, as illustrated by our tests,
calling ap_set_content_length on a HEAD request, even when no bytes are
sent, results in a set C-L header. while I think this is the proper
behavior, from the comments and the above patch it would seem that this was
_not_ intended. does r->bytes_sent include headers themselves? if so, then
it seems the logic in the above patch is wrong - I think he means to count
the body?
anyway, the attached patch passes for me on 2.0.52 and current 2.1.
discussion welcome.
--Geoff
Index: t/apache/content_length_header.t
===================================================================
RCS file: /home/cvs/modperl-2.0/t/apache/content_length_header.t,v
retrieving revision 1.3
diff -u -r1.3 content_length_header.t
--- t/apache/content_length_header.t 5 Aug 2004 12:54:10 -0000 1.3
+++ t/apache/content_length_header.t 30 Sep 2004 18:07:16 -0000
@@ -36,26 +36,40 @@
{
# if the response handler sends no data, and sets no C-L header,
- # the client doesn't get C-L header for HEAD requests due to
- # special processing. GET requests get a C-L of zero.
+ # the client doesn't get C-L header at all.
+ #
+ # in 2.0 GET requests get a C-L of zero, while HEAD requests do
+ # not due to special processing.
my $uri = $location;
my $res = $method->($uri);
+
+ my $cl = have_min_apache_version(2.1) ? undef : 0;
+ my $head_cl = have_min_apache_version(2.1) ? $cl : undef;
+
ok t_cmp $res->code, 200, "$method $uri code";
ok t_cmp ($res->header('Content-Length'),
- $method eq 'GET' ? 0 : undef,
+ $method eq 'GET' ? $cl : $head_cl,
"$method $uri C-L header");
ok t_cmp $res->content, "", "$method $uri content";
}
{
- # if the response handler sends no data, and sets C-L header,
- # the client doesn't get C-L header for HEAD requests due to
- # special processing. GET requests get a C-L of zero.
+ # if the response handler sends no data and sets C-L header,
+ # the client should receive the set content length. in 2.1
+ # this is the way it happens. see protocol.c -r1.150 -r1.151
+ #
+ # in 2.0 the client doesn't get C-L header for HEAD requests
+ # due to special processing, and GET requests get a calculated
+ # C-L of zero.
my $uri = "$location?set_content_length";
my $res = $method->($uri);
+
+ my $cl = have_min_apache_version(2.1) ? 25 : 0;
+ my $head_cl = have_min_apache_version(2.1) ? $cl : undef;
+
ok t_cmp $res->code, 200, "$method $uri code";
ok t_cmp ($res->header('Content-Length'),
- $method eq 'GET' ? 0 : undef,
+ $method eq 'GET' ? $cl : $head_cl,
"$method $uri C-L header");
ok t_cmp $res->content, "", "$method $uri content";
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]