You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Robert S. Thau" <rs...@ai.mit.edu> on 1996/06/15 16:49:52 UTC

r->bytes_sent patch...

This is a patch which restores the r->bytes_sent field to request_recs.
I would *really* like to see this in 1.1 final, if not before.  (NB
I've modified mod_log_common to use r->bytes_sent so I could test it,
but left the other loggers intact as insurance against disaster...).

diff -c ../src.dist.ref/http_protocol.c ./http_protocol.c
*** ../src.dist.ref/http_protocol.c	Sat Jun 15 10:05:48 1996
--- ./http_protocol.c	Sat Jun 15 10:03:36 1996
***************
*** 71,76 ****
--- 71,81 ----
  
  #include <stdarg.h>
  
+ #define SET_BYTES_SENT(r) \
+   do { if (r->sent_bodyct) \
+ 	  bgetopt (r->connection->client, BO_BYTECT, &r->bytes_sent); \
+   } while (0)
+ 
  /* Handling of conditional gets (if-modified-since); Roy owes Rob beer. 
   * This would be considerably easier if strptime or timegm were portable...
   */
***************
*** 500,505 ****
--- 505,511 ----
  
  void finalize_sub_req_protocol (request_rec *sub)
  {
+     SET_BYTES_SENT (sub->main);
  } 
  
  /* Support for the Basic authentication protocol, and a bit for Digest.
***************
*** 752,757 ****
--- 758,764 ----
      }
      bflush(c->client);
      
+     SET_BYTES_SENT(r);
      return total_bytes_sent;
  }
  
***************
*** 759,764 ****
--- 766,772 ----
  {
      if (r->connection->aborted) return EOF;
      bputc(c, r->connection->client);
+     SET_BYTES_SENT(r);
      return c;
  }
  
***************
*** 766,771 ****
--- 774,780 ----
  rputs(const char *str, request_rec *r)
  {
      if (r->connection->aborted) return EOF;
+     SET_BYTES_SENT(r);
      return bputs(str, r->connection->client);
  }
  
***************
*** 778,783 ****
--- 787,793 ----
      va_start(vlist,fmt);
      n=vbprintf(r->connection->client,fmt,vlist);
      va_end(vlist);
+     SET_BYTES_SENT(r);
      return n;
      }
  
***************
*** 807,812 ****
--- 817,823 ----
      }
      va_end(args);
  
+     SET_BYTES_SENT(r);
      return k;
  }
  
Only in .: http_protocol.c~
diff -c ../src.dist.ref/httpd.h ./httpd.h
*** ../src.dist.ref/httpd.h	Sat Jun 15 10:05:48 1996
--- ./httpd.h	Sat Jun 15 09:57:34 1996
***************
*** 353,358 ****
--- 353,359 ----
    int method_number;		/* M_GET, M_POST, etc. */
  
    int sent_bodyct;		/* byte count in stream is for body */
+   long bytes_sent;		/* body byte count, for easy access */
    
    /* MIME header environments, in and out.  Also, an array containing
     * environment variables to be passed to subprocesses, so people can
Only in .: httpd.h~
diff -c ../src.dist.ref/mod_log_common.c ./mod_log_common.c
*** ../src.dist.ref/mod_log_common.c	Sat Jun 15 10:05:49 1996
--- ./mod_log_common.c	Sat Jun 15 10:04:29 1996
***************
*** 182,194 ****
      if (r->status != -1) sprintf(status,"%d ", r->status);
      else                 strcpy(status, "- ");
  
!     if (r->sent_bodyct)
!     {
! 	long int bs;
! 
! 	bgetopt(r->connection->client, BO_BYTECT, &bs);
! 	sprintf(&status[strlen(status)], "%ld\n", bs);
!     }
      else
          strcat(status, "-\n");
  
--- 182,189 ----
      if (r->status != -1) sprintf(status,"%d ", r->status);
      else                 strcpy(status, "- ");
  
!     if (r->bytes_sent > 0) 
! 	sprintf(&status[strlen(status)], "%ld\n", r->bytes_sent);
      else
          strcat(status, "-\n");
  
Only in .: mod_log_common.c~
Only in .: patch.bytes_sent