In case of missing server data, send no error message to the client if the request...
authorFabian Keil <fk@fabiankeil.de>
Sun, 4 Oct 2009 15:34:18 +0000 (15:34 +0000)
committerFabian Keil <fk@fabiankeil.de>
Sun, 4 Oct 2009 15:34:18 +0000 (15:34 +0000)
The client is then supposed to silently retry the request without
bothering the user. At least Firefox actually does that.

jcc.c
project.h

diff --git a/jcc.c b/jcc.c
index 5976e9e..d15cbf0 100644 (file)
--- 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
          {
index d53aab4..c8ff384 100644 (file)
--- 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
  */