-const char jcc_rcs[] = "$Id: jcc.c,v 1.250 2009/05/16 13:27:20 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 $
"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"
"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 *);
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;
{
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;
}
{
log_error(LOG_LEVEL_ERROR,
"Stopped grabbing the client headers.");
+ destroy_list(headers);
return JB_ERR_PARSE;
}
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);
}
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);
"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;
*/
if (FD_ISSET(csp->sfd, &rfds))
{
- fflush(0);
+ fflush(NULL);
len = read_socket(csp->sfd, buf, sizeof(buf) - 1);
if (len < 0)
{
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;