Use the connect-failed template when the forwarding proxy fails
[privoxy.git] / jcc.c
diff --git a/jcc.c b/jcc.c
index a76851c..d0f0b34 100644 (file)
--- a/jcc.c
+++ b/jcc.c
@@ -3884,16 +3884,18 @@ static void chat(struct client_state *csp)
             }
 
             /*
-             * Test if connection with destination server was established
-             * successfully by parent proxy. Then we can send response to
-             * the client and continue or stop.
+             * Test if the connection to the destination server was
+             * established successfully by the parent proxy.
              */
             if (!tunnel_established_successfully(server_response, (unsigned int)len))
             {
                log_error(LOG_LEVEL_ERROR, "Forwarder hasn't established "
                   "connection with destination server.");
-
-               write_socket(csp->cfd, server_response, (size_t)len);
+               rsp = error_response(csp, "connect-failed");
+               if (rsp)
+               {
+                  send_crunch_response(csp, rsp);
+               }
                mark_server_socket_tainted(csp);
                close_client_ssl_connection(csp);
                return;