In case of missing server data, send no error message to the client if the request...
[privoxy.git] / jcc.c
diff --git a/jcc.c b/jcc.c
index a09621e..d15cbf0 100644 (file)
--- a/jcc.c
+++ b/jcc.c
@@ -1,4 +1,4 @@
-const char jcc_rcs[] = "$Id: jcc.c,v 1.294 2009/09/18 18:57:20 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;
@@ -2488,7 +2499,7 @@ static void serve(struct client_state *csp)
       chat(csp);
 
       latency = (unsigned)(csp->server_connection.response_received -
-         csp->server_connection.request_sent);
+         csp->server_connection.request_sent) / 2;
 
       continue_chatting = (csp->config->feature_flags
          & RUNTIME_FEATURE_CONNECTION_KEEP_ALIVE)
@@ -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
          {
@@ -2563,7 +2575,7 @@ static void serve(struct client_state *csp)
                   break;
                }
 
-               remember_connection(csp, forward_url(csp, csp->http));
+               remember_connection(&csp->server_connection);
                csp->sfd = JB_INVALID_SOCKET;
                close_socket(csp->cfd);
                csp->cfd = JB_INVALID_SOCKET;