The %b option is used to log the 'bytes_sent' in a reply. Unlike %B, %b should log a '-' rather than '0' if no body is sent on a reply. I recently ran across two cases where %b incorrectly logs '0': First case is when ap_set_byterange sets HTTP_RANGE_NOT_SATISFIABLE to the default_handler. Second case is when mod_dav returns a status 200 to an OPTIONS request.

The fix is to not set r->sent_bodyct in ap_send_http_header() if r->header_only is 
set.  Here is the patch:

Index: http_protocol.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/main/http_protocol.c,v
retrieving revision 1.335
diff -u -r1.335 http_protocol.c
--- http_protocol.c     15 Apr 2004 15:51:51 -0000      1.335
+++ http_protocol.c     1 Jul 2004 02:46:08 -0000
@@ -1887,7 +1887,9 @@
     ap_kill_timeout(r);

     ap_bsetopt(r->connection->client, BO_BYTECT, &zero);
-    r->sent_bodyct = 1;         /* Whatever follows is real body stuff... */
+    if (!r->header_only) {
+        r->sent_bodyct = 1;         /* Whatever follows is real body stuff... */
+    }

     /* Set buffer flags for the body */
     if (r->chunked)


Will this break anyone?

Bill

Reply via email to