From 13c2297e5c789e5bfb38efd37af0e8b7f944096a Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sun, 4 Oct 2009 15:34:18 +0000 Subject: [PATCH] In case of missing server data, send no error message to the client if the request arrived on a reused connection. The client is then supposed to silently retry the request without bothering the user. At least Firefox actually does that. --- jcc.c | 22 +++++++++++++++++----- project.h | 7 ++++++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/jcc.c b/jcc.c index 5976e9e3..d15cbf0f 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.296 2009/10/01 16:07:34 fabiankeil Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.297 2009/10/03 10:37:49 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -2304,10 +2304,21 @@ static void chat(struct client_state *csp) /* Did we actually get anything? */ if (NULL == csp->headers->first) { - log_error(LOG_LEVEL_ERROR, - "Empty server or forwarder response received on socket %d.", csp->sfd); + if ((csp->flags & CSP_FLAG_REUSED_CLIENT_CONNECTION)) + { + log_error(LOG_LEVEL_ERROR, + "Empty server or forwarder response received on socket %d. " + "Closing client connection %d without sending data.", + csp->sfd, csp->cfd); + } + else + { + log_error(LOG_LEVEL_ERROR, + "Empty server or forwarder response received on socket %d.", + csp->sfd); + send_crunch_response(csp, error_response(csp, "no-server-data")); + } log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 502 0", csp->ip_addr_str, http->cmd); - send_crunch_response(csp, error_response(csp, "no-server-data")); free_http_request(http); mark_server_socket_tainted(csp); return; @@ -2546,7 +2557,8 @@ static void serve(struct client_state *csp) } /* XXX: Store per-connection flags someplace else. */ - csp->flags = CSP_FLAG_ACTIVE | (csp->flags & CSP_FLAG_TOGGLED_ON); + csp->flags = CSP_FLAG_ACTIVE | + (csp->flags & CSP_FLAG_TOGGLED_ON) | CSP_FLAG_REUSED_CLIENT_CONNECTION; } else { diff --git a/project.h b/project.h index d53aab43..c8ff3843 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.148 2009/07/18 12:20:05 fabiankeil Exp $" +#define PROJECT_H_VERSION "$Id: project.h,v 1.149 2009/08/19 15:57:13 fabiankeil Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/project.h,v $ @@ -788,6 +788,11 @@ struct reusable_connection */ #define CSP_FLAG_SERVER_PROXY_CONNECTION_HEADER_SET 0x00080000U +/** + * Flag for csp->flags: Set if the client reused its connection. + */ +#define CSP_FLAG_REUSED_CLIENT_CONNECTION 0x00100000U + /* * Flags for use in return codes of child processes */ -- 2.39.2