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

mathewm at sdf.lonestar.org mathewm at sdf.lonestar.org
Sun May 26 04:26:50 UTC 2013


On Thu, 28 Mar 2013 10:37:10 +0100, Victor Julien <victor at inliniac.net> 
wrote:
>On 03/23/2013 10:46 AM, mathewm at sdf.lonestar.org wrote:
>> 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.
>
>Interesting addition. Was going to apply it, but my git rejects it. Can
>you retry sending it against the current master, or attach a "git
>format-patch -1" file? A github pr works as well.
>
>Cheers,
>Victor

Sorry for the delay, I need to pay more attention to my email!

A corrected patch file is attached, which I managed to successfully test 
locally so with any luck this one will be OK.

Cheers

Mat
-------------- next part --------------
From 25f78bc4d640622cadbfe139792787c8d7af8c60 Mon Sep 17 00:00:00 2001
From: Mathew Meins <mathewm at sdf.lonestar.org>
Date: Sun, 26 May 2013 14:06:03 +1000
Subject: [PATCH] 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 abc5811..291a6c3 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.9.6 (Apple Git-31.1)



More information about the Oisf-devel mailing list