From: Fabian Keil Date: Thu, 11 Jun 2009 11:49:11 +0000 (+0000) Subject: Send a template-based response in case of prematurely closed connections. X-Git-Tag: v_3_0_13~28 X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=commitdiff_plain;h=effa99e4df3dbc95aafd3dd940c0454ca0a2ce44 Send a template-based response in case of prematurely closed connections. --- diff --git a/cgi.c b/cgi.c index ee25909e..20f2fc42 100644 --- a/cgi.c +++ b/cgi.c @@ -1,4 +1,4 @@ -const char cgi_rcs[] = "$Id: cgi.c,v 1.121 2009/06/11 11:46:22 fabiankeil Exp $"; +const char cgi_rcs[] = "$Id: cgi.c,v 1.122 2009/06/11 11:47:16 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgi.c,v $ @@ -950,6 +950,11 @@ struct http_response *error_response(struct client_state *csp, rsp->status = strdup("504 Connection timeout"); rsp->reason = RSP_REASON_CONNECTION_TIMEOUT; } + else if (!strcmp(templatename, "no-server-data")) + { + rsp->status = strdup("502 No data received from server or forwarder"); + rsp->reason = RSP_REASON_NO_SERVER_DATA; + } if (rsp->status == NULL) { diff --git a/jcc.c b/jcc.c index cc37def1..de6d35b2 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.254 2009/06/11 11:44:25 fabiankeil Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.255 2009/06/11 11:46:22 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -236,15 +236,6 @@ static const char MISSING_DESTINATION_RESPONSE[] = "Connection: close\r\n\r\n" "Bad request. Privoxy was unable to extract the destination.\r\n"; -/* XXX: should be a template */ -static const char NO_SERVER_DATA_RESPONSE[] = - "HTTP/1.0 502 Server or forwarder response empty\r\n" - "Proxy-Agent: Privoxy " VERSION "\r\n" - "Content-Type: text/plain\r\n" - "Connection: close\r\n\r\n" - "Empty server or forwarder response.\r\n" - "The connection has been closed but Privoxy didn't receive any data.\r\n"; - /* XXX: should be a template */ static const char INVALID_SERVER_HEADERS_RESPONSE[] = "HTTP/1.0 502 Server or forwarder response invalid\r\n" @@ -2099,7 +2090,7 @@ static void chat(struct client_state *csp) { log_error(LOG_LEVEL_ERROR, "Empty server or forwarder response."); log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 502 0", csp->ip_addr_str, http->cmd); - write_socket(csp->cfd, NO_SERVER_DATA_RESPONSE, strlen(NO_SERVER_DATA_RESPONSE)); + send_crunch_response(csp, error_response(csp, "no-server-data")); free_http_request(http); mark_server_socket_tainted(csp); return; diff --git a/project.h b/project.h index 71357600..4d0d9863 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.140 2009/06/08 16:47:07 fabiankeil Exp $" +#define PROJECT_H_VERSION "$Id: project.h,v 1.141 2009/06/11 11:46:22 fabiankeil Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/project.h,v $ @@ -319,6 +319,7 @@ struct http_request #define RSP_REASON_OUT_OF_MEMORY 9 #define RSP_REASON_INTERNAL_ERROR 10 #define RSP_REASON_CONNECTION_TIMEOUT 11 +#define RSP_REASON_NO_SERVER_DATA 12 /** * Response generated by CGI, blocker, or error handler diff --git a/templates/no-server-data b/templates/no-server-data new file mode 100644 index 00000000..f752476c --- /dev/null +++ b/templates/no-server-data @@ -0,0 +1,95 @@ +########################################################## +# +# no-server-data Error Output template for Privoxy. +# +########################################################## + + + + + 502 - No server or forwarder data received (Privoxy@@my-hostname@) + + + + + + + + + + + + + + + + + +# This will only appear if CODE_STATUS is "alpha" or "beta". See configure.in + + + + + + + + + + + + + + + + + + + + + + + +
+ 502 + + +#include mod-title + +
+ +#include mod-unstable-warning + +
+

No server or forwarder data received

+

Your request for @protocol@@hostport@@path@ + could not be fulfilled, because the connection to @host@ (@host-ip@) has been closed + before Privoxy received any data for this request. +

+

This is often a temporary failure, so you might just + try again. +

+

+ If you get this message very often, consider disabling + connection-sharing + (which should be off by default). If that doesn't help, you may have to additionally + disable support for connection keep-alive by setting + keep-alive-timeout + to 0. +

+
+

More Privoxy:

+ +
+ +#include mod-support-and-service + +
+ +#include mod-local-help + +
+ + +