]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
DW:
authorwessels <>
Sat, 25 Mar 2000 11:58:39 +0000 (11:58 +0000)
committerwessels <>
Sat, 25 Mar 2000 11:58:39 +0000 (11:58 +0000)
 - binary HTTP header logging.  Gives better stats than 'headers'
   from cachemgr.

src/access_log.cc
src/client_side.cc
src/http.cc
src/protos.h

index c187a347a9f1a2ca0c869cc7d1fd196dc2f2dc64..fc2255d9f42b1f2f4f7ab76a2234fe04b7997430 100644 (file)
@@ -1,7 +1,7 @@
 
 
 /*
- * $Id: access_log.cc,v 1.55 2000/03/14 23:07:51 wessels Exp $
+ * $Id: access_log.cc,v 1.56 2000/03/25 04:58:39 wessels Exp $
  *
  * DEBUG: section 46    Access Log
  * AUTHOR: Duane Wessels
@@ -41,6 +41,9 @@ static char *log_quote(const char *header);
 static void accessLogSquid(AccessLogEntry * al);
 static void accessLogCommon(AccessLogEntry * al);
 static Logfile *logfile = NULL;
+#if HEADERS_LOG
+static Logfile *headerslog = NULL;
+#endif
 
 #if MULTICAST_MISS_STREAM
 static int mcast_miss_fd = -1;
@@ -298,6 +301,9 @@ accessLogRotate(void)
     if (NULL == logfile)
        return;
     logfileRotate(logfile);
+#if HEADERS_LOG
+    logfileRotate(headerslog);
+#endif
 }
 
 void
@@ -305,6 +311,10 @@ accessLogClose(void)
 {
     logfileClose(logfile);
     logfile = NULL;
+#if HEADERS_LOG
+    logfileClose(headerslog);
+    headerslog = NULL;
+#endif
 }
 
 void
@@ -323,6 +333,10 @@ accessLogInit(void)
     assert(sizeof(log_tags) == (LOG_TYPE_MAX + 1) * sizeof(char *));
     logfile = logfileOpen(Config.Log.access, MAX_URL << 1);
     LogfileStatus = LOG_ENABLE;
+#if HEADERS_LOG
+    headerslog = logfileOpen("/usr/local/squid/logs/headers.log", 512);
+    assert(NULL != headerslog);
+#endif
 #if FORW_VIA_DB
     fvdbInit();
 #endif
@@ -488,3 +502,54 @@ mcast_encode(unsigned int *ibuf, size_t isize, const unsigned int *key)
 }
 
 #endif
+
+#if HEADERS_LOG
+void
+headersLog(int cs, int pq, method_t m, void *data)
+{
+    HttpReply *rep;
+    request_t *req;
+    unsigned short magic = 0;
+    unsigned char M = (unsigned char) m;
+    unsigned short S;
+    char *hmask;
+    int ccmask = 0;
+    if (0 == pq) {
+       /* reply */
+       rep = data;
+       req = NULL;
+       magic = 0x0050;
+       hmask = rep->header.mask;
+       if (rep->cache_control)
+           ccmask = rep->cache_control->mask;
+    } else {
+       /* request */
+       req = data;
+       rep = NULL;
+       magic = 0x0051;
+       hmask = req->header.mask;
+       if (req->cache_control)
+           ccmask = req->cache_control->mask;
+    }
+    if (0 == cs) {
+       /* client */
+       magic |= 0x4300;
+    } else {
+       /* server */
+       magic |= 0x5300;
+    }
+    magic = htons(magic);
+    ccmask = htonl(ccmask);
+    if (0 == pq)
+       S = (unsigned short) rep->sline.status;
+    else
+       S = (unsigned short) HTTP_STATUS_NONE;
+    logfileWrite(headerslog, &magic, sizeof(magic));
+    logfileWrite(headerslog, &M, sizeof(M));
+    logfileWrite(headerslog, &S, sizeof(S));
+    logfileWrite(headerslog, hmask, sizeof(HttpHeaderMask));
+    logfileWrite(headerslog, &ccmask, sizeof(int));
+    logfileFlush(headerslog);
+}
+
+#endif
index 3dd0d73ea5ff4dcd7504ac8fbdd40a519a1de355..effce9f334c948eb112f55da694aa7a803e81f99 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.471 2000/03/06 16:23:29 wessels Exp $
+ * $Id: client_side.cc,v 1.472 2000/03/25 04:58:39 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -1699,6 +1699,9 @@ clientSendMoreData(void *data, char *buf, ssize_t size)
        http->out.offset += rep->hdr_sz;
        check_size += rep->hdr_sz;
        httpReplyDestroy(rep);
+#if HEADERS_LOG
+       headersLog(0, 0, http->request->method, rep);
+#endif
        rep = NULL;
     } else {
        memBufDefInit(&mb);
@@ -2511,6 +2514,9 @@ clientReadRequest(int fd, void *data)
                    break;
                }
            }
+#if HEADERS_LOG
+           headersLog(0, 1, request->method, request);
+#endif
            clientAccessCheck(http);
            continue;           /* while offset > 0 */
        } else if (parser_return_code == 0) {
index 571ac13dc868acf0c83bbac8b00055f7d1a21743..2272a0db7df31dbeae26ab3e2c92c9eb406f8fb2 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.356 2000/03/06 16:23:32 wessels Exp $
+ * $Id: http.cc,v 1.357 2000/03/25 04:58:39 wessels Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -393,6 +393,9 @@ httpProcessReplyHeader(HttpStateData * httpState, const char *buf, int size)
                httpState->request->host, skew);
     }
     ctx_exit(ctx);
+#if HEADERS_LOG
+    headersLog(1, 0, httpState->request->method, reply);
+#endif
 }
 
 static int
index 121c2beb9b58b1c4bac2fcdcc564ab7dc643d922..8d5f28053d43114610f067a22bc7344ee22e6c17 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.357 2000/03/14 23:11:05 wessels Exp $
+ * $Id: protos.h,v 1.358 2000/03/25 04:58:40 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -41,6 +41,9 @@ extern void hierarchyNote(HierarchyLogEntry *, hier_code, const char *);
 extern void fvdbCountVia(const char *key);
 extern void fvdbCountForw(const char *key);
 #endif
+#if HEADERS_LOG
+extern void headersLog(int cs, int pq, method_t m, void *data);
+#endif
 
 extern aclCheck_t *aclChecklistCreate(const struct _acl_access *,
     request_t *,