X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=jcc.c;h=de6d35b2075c58672543671c50f0c668f850193c;hb=d10c062399534f3619e2cf10d7c768037596333b;hp=42c42b4b6471131901f788adc21ec846c6214317;hpb=ed2a7ea89af6c90de15876c6e9b378ef93c2fee0;p=privoxy.git diff --git a/jcc.c b/jcc.c index 42c42b4b..de6d35b2 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.251 2009/06/03 16:42:49 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" @@ -278,13 +269,12 @@ static const char TOO_MANY_CONNECTIONS_RESPONSE[] = "Connection: close\r\n\r\n" "Maximum number of open connections reached.\r\n"; -/* XXX: should be a template */ -static const char CONNECTION_TIMEOUT_RESPONSE[] = +static const char CLIENT_CONNECTION_TIMEOUT_RESPONSE[] = "HTTP/1.0 504 Connection timeout\r\n" "Proxy-Agent: Privoxy " VERSION "\r\n" "Content-Type: text/plain\r\n" "Connection: close\r\n\r\n" - "The connection timed out.\r\n"; + "The connection timed out because the client request didn't arrive in time.\r\n"; /* A function to crunch a response */ typedef struct http_response *(*crunch_func_ptr)(struct client_state *); @@ -664,6 +654,9 @@ static const char *crunch_reason(const struct http_response *rsp) case RSP_REASON_OUT_OF_MEMORY: reason = "Out of memory (may mask other reasons)"; break; + case RSP_REASON_CONNECTION_TIMEOUT: + reason = "Connection timeout"; + break; default: reason = "No reason recorded"; break; @@ -1176,8 +1169,8 @@ static char *get_request_line(struct client_state *csp) { log_error(LOG_LEVEL_ERROR, "Stopped waiting for the request line."); - write_socket(csp->cfd, CONNECTION_TIMEOUT_RESPONSE, - strlen(CONNECTION_TIMEOUT_RESPONSE)); + write_socket(csp->cfd, CLIENT_CONNECTION_TIMEOUT_RESPONSE, + strlen(CLIENT_CONNECTION_TIMEOUT_RESPONSE)); return NULL; } @@ -1635,15 +1628,15 @@ static void chat(struct client_state *csp) if (fwd->type != SOCKS_NONE) { /* Socks error. */ - rsp = error_response(csp, "forwarding-failed", errno); + rsp = error_response(csp, "forwarding-failed"); } else if (errno == EINVAL) { - rsp = error_response(csp, "no-such-domain", errno); + rsp = error_response(csp, "no-such-domain"); } else { - rsp = error_response(csp, "connect-failed", errno); + rsp = error_response(csp, "connect-failed"); log_error(LOG_LEVEL_CONNECT, "connect to: %s failed: %E", http->hostport); } @@ -1682,7 +1675,7 @@ static void chat(struct client_state *csp) log_error(LOG_LEVEL_CONNECT, "write header to: %s failed: %E", http->hostport); - rsp = error_response(csp, "connect-failed", errno); + rsp = error_response(csp, "connect-failed"); if (rsp) { send_crunch_response(csp, rsp); @@ -1772,8 +1765,7 @@ static void chat(struct client_state *csp) "Didn't receive data in time: %s", http->url); if ((byte_count == 0) && (http->ssl == 0)) { - write_socket(csp->cfd, CONNECTION_TIMEOUT_RESPONSE, - strlen(CONNECTION_TIMEOUT_RESPONSE)); + send_crunch_response(csp, error_response(csp, "connection-timeout")); } mark_server_socket_tainted(csp); return; @@ -1819,7 +1811,7 @@ static void chat(struct client_state *csp) */ if (FD_ISSET(csp->sfd, &rfds)) { - fflush(0); + fflush(NULL); len = read_socket(csp->sfd, buf, sizeof(buf) - 1); if (len < 0) @@ -2098,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;