[Oisf-devel] [PATCH] Added request length to custom HTTP logging

mathewm at sdf.lonestar.org mathewm at sdf.lonestar.org
Sat Mar 23 09:46:38 UTC 2013


Added request length to custom HTTP logging

Custom HTTP logging currently provides access to the HTTP response length 
(via %B in the custom log format string), but not the request length. The 
request length can be very valuable.

I've modified log-httplog.c to provide access to libhtp's 
request_message_len, via %b in the custom log format.

---
  src/log-httplog.c | 5 +++++
  1 file changed, 5 insertions(+)

diff --git a/src/log-httplog.c b/src/log-httplog.c
index f4c6b42..6db5432 100644
--- a/src/log-httplog.c
+++ b/src/log-httplog.c
@@ -108,6 +108,7 @@ void TmModuleLogHttpLogIPv6Register (void) {
  #define LOG_HTTP_CF_REQUEST_TIME 't'
  #define LOG_HTTP_CF_REQUEST_HEADER 'i'
  #define LOG_HTTP_CF_REQUEST_COOKIE 'C'
+#define LOG_HTTP_CF_REQUEST_LEN 'b'
  #define LOG_HTTP_CF_RESPONSE_STATUS 's'
  #define LOG_HTTP_CF_RESPONSE_HEADER 'o'
  #define LOG_HTTP_CF_RESPONSE_LEN 'B'
@@ -264,6 +265,10 @@ static void LogHttpLogCustom(LogHttpLogThread *aft, htp_tx_t *tx, const struct t
                      MemBufferWriteString(aft->buffer, LOG_HTTP_CF_NONE);
                  }
                  break;
+            case LOG_HTTP_CF_REQUEST_LEN:
+            /* REQUEST LEN */
+                MemBufferWriteString(aft->buffer, "%"PRIuMAX"", (uintmax_t)tx->request_message_len);
+                break;
              case LOG_HTTP_CF_RESPONSE_STATUS:
              /* RESPONSE STATUS */
                  if (tx->response_status != NULL) {
-- 
1.7.12.4 (Apple Git-37)



More information about the Oisf-devel mailing list