From 152d6935a413a5fc6b49a4d76f475b06b04806f6 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sun, 12 Oct 2008 15:57:35 +0000 Subject: [PATCH] Fix content length calculation if we read headers and the start of the body at once. Now that we have FEATURE_CONNECTION_KEEP_ALIVE, it actually matters. --- jcc.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/jcc.c b/jcc.c index 9364300c..8f4a8400 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.191 2008/10/11 18:00:14 fabiankeil Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.192 2008/10/11 18:19:14 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -33,6 +33,9 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.191 2008/10/11 18:00:14 fabiankeil Exp $" * * Revisions : * $Log: jcc.c,v $ + * Revision 1.192 2008/10/11 18:19:14 fabiankeil + * Even more chat() cosmetics. + * * Revision 1.191 2008/10/11 18:00:14 fabiankeil * Reformat some comments in chat(). * @@ -2797,6 +2800,7 @@ static void chat(struct client_state *csp) } else { + const char *header_start; /* * We're still looking for the end of the server's header. * Buffer up the data we just read. If that fails, there's @@ -2811,6 +2815,8 @@ static void chat(struct client_state *csp) return; } + header_start = csp->iob->cur; + /* Convert iob into something sed() can digest */ if (JB_ERR_PARSE == get_server_headers(csp)) { @@ -2834,6 +2840,16 @@ static void chat(struct client_state *csp) continue; } } + else + { + /* + * XXX: the header lenght should probably + * be calculated by get_server_headers(). + */ + int header_length = csp->iob->cur - header_start; + assert(csp->iob->cur > header_start); + byte_count += len - header_length; + } /* Did we actually get anything? */ if (NULL == csp->headers->first) -- 2.39.2