From c0c1d276faa0a9b2259bd3ced8f1c3fbd64abb22 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Mon, 8 Jun 2009 16:47:07 +0000 Subject: [PATCH] Don't force the client to wait for the connection to timeout if we modified the content, the client asked for keep-alive and there's no Content-Length header present. --- parsers.c | 24 +++++++++++++++++++++++- project.h | 13 ++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/parsers.c b/parsers.c index 74c5dd31..15c5cbdf 100644 --- a/parsers.c +++ b/parsers.c @@ -1,4 +1,4 @@ -const char parsers_rcs[] = "$Id: parsers.c,v 1.174 2009/06/05 16:54:27 fabiankeil Exp $"; +const char parsers_rcs[] = "$Id: parsers.c,v 1.175 2009/06/05 16:55:16 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/parsers.c,v $ @@ -1151,6 +1151,27 @@ jb_err update_server_headers(struct client_state *csp) } } +#ifdef FEATURE_CONNECTION_KEEP_ALIVE + if ((JB_ERR_OK == err) + && (csp->flags & CSP_FLAG_MODIFIED) + && (csp->flags & CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE) + && !(csp->flags & CSP_FLAG_SERVER_CONTENT_LENGTH_SET)) + { + /* + * XXX: lame. should factor the regeneration code out + * of server_adjust_content_length instead. + */ + log_error(LOG_LEVEL_HEADER, + "Content modified with no Content-Length header set. " + "Creating a fake one for adjustment later on."); + err = enlist(csp->headers, "Content-Length: 0"); + if (JB_ERR_OK == err) + { + err = server_adjust_content_length(csp, &(csp->headers->last->str)); + } + } +#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */ + return err; } @@ -2098,6 +2119,7 @@ static jb_err server_save_content_length(struct client_state *csp, char **header else { csp->expected_content_length = content_length; + csp->flags |= CSP_FLAG_SERVER_CONTENT_LENGTH_SET; csp->flags |= CSP_FLAG_CONTENT_LENGTH_SET; } diff --git a/project.h b/project.h index 8f1fc469..b4a7020e 100644 --- a/project.h +++ b/project.h @@ -1,7 +1,7 @@ #ifndef PROJECT_H_INCLUDED #define PROJECT_H_INCLUDED /** Version string. */ -#define PROJECT_H_VERSION "$Id: project.h,v 1.138 2009/05/16 13:27:20 fabiankeil Exp $" +#define PROJECT_H_VERSION "$Id: project.h,v 1.139 2009/06/03 16:42:49 fabiankeil Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/project.h,v $ @@ -739,13 +739,20 @@ struct reusable_connection * Flag for csp->flags: Set if the server specified the * content length. */ -#define CSP_FLAG_CONTENT_LENGTH_SET 0x00002000U +#define CSP_FLAG_SERVER_CONTENT_LENGTH_SET 0x00002000U + +/** + * Flag for csp->flags: Set if we know the content lenght, + * either because the server set it, or we figured it out + * on our own. + */ +#define CSP_FLAG_CONTENT_LENGTH_SET 0x00004000U /** * Flag for csp->flags: Set if the client wants to keep * the connection alive. */ -#define CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE 0x00004000U +#define CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE 0x00008000U #endif /* def FEATURE_CONNECTION_KEEP_ALIVE */ /* -- 2.49.0