-const char jcc_rcs[] = "$Id: jcc.c,v 1.117 2006/12/31 17:56:37 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.118 2007/01/07 07:43:43 joergs Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
* Purpose : Main file. Contains main() method, main loop, and
* the main connection-handling function.
*
- * Copyright : Written by and Copyright (C) 2001 the SourceForge
+ * Copyright : Written by and Copyright (C) 2001-2007 the SourceForge
* Privoxy team. http://www.privoxy.org/
*
* Based on the Internet Junkbuster originally written
*
* Revisions :
* $Log: jcc.c,v $
+ * Revision 1.118 2007/01/07 07:43:43 joergs
+ * AmigaOS4 support added.
+ *
* Revision 1.117 2006/12/31 17:56:37 fabiankeil
* Added config option accept-intercepted-requests
* and disabled it by default.
const char CFORBIDDEN[] =
"HTTP/1.0 403 Connection not allowable\r\n"
+ "Proxy-Agent: Privoxy " VERSION "\r\n"
"X-Hint: If you read this message interactively, then you know why this happens ,-)\r\n"
"Connection: close\r\n\r\n";
"Connection: close\r\n\r\n"
"Invalid request. Privoxy doesn't support gopher.\r\n";
+/* XXX: should be a template */
const char MISSING_DESTINATION_RESPONSE[] =
"HTTP/1.0 400 Bad request received from browser\r\n"
+ "Proxy-Agent: Privoxy " VERSION "\r\n"
"Connection: close\r\n\r\n"
"Bad request. Privoxy was unable to extract the destination.\r\n";
+/* XXX: should be a template */
+const char NO_SERVER_DATA_RESPONSE[] =
+ "HTTP/1.0 502 Server or forwarder response empty\r\n"
+ "Proxy-Agent: Privoxy " VERSION "\r\n"
+ "Connection: close\r\n\r\n"
+ "Empty server or forwarder response.\r\n"
+ "The connection was closed without sending any data.\r\n";
#if !defined(_WIN32) && !defined(__OS2__) && !defined(AMIGA)
/*********************************************************************
if (csp->sfd == JB_INVALID_SOCKET)
{
- log_error(LOG_LEVEL_CONNECT, "connect to: %s failed: %E",
- http->hostport);
+ if (fwd->type != SOCKS_NONE)
+ {
+ /* Socks error. */
+ rsp = error_response(csp, "forwarding-failed", errno);
- if (errno == EINVAL)
+ log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 503 0",
+ csp->ip_addr_str, http->ocmd);
+ }
+ else if (errno == EINVAL)
{
rsp = error_response(csp, "no-such-domain", errno);
{
rsp = error_response(csp, "connect-failed", errno);
+ log_error(LOG_LEVEL_CONNECT, "connect to: %s failed: %E",
+ http->hostport);
+
log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 503 0",
csp->ip_addr_str, http->ocmd);
}
return;
}
- log_error(LOG_LEVEL_CONNECT, "OK");
-
if (fwd->forward_host || (http->ssl == 0))
{
/* write the client's (modified) header to the server
IOB_RESET(csp);
}
+ log_error(LOG_LEVEL_CONNECT, "to %s successful", http->hostport);
+
/* we're finished with the client's header */
freez(hdr);
}
}
+ /* Did we actually get anything? */
+ if (NULL == csp->headers->first)
+ {
+ 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);
+ strcpy(buf, NO_SERVER_DATA_RESPONSE);
+ write_socket(csp->cfd, buf, strlen(buf));
+ free_http_request(http);
+ return;
+ }
+
/* we have now received the entire header.
* filter it and send the result to the client
*/
bfd = bind_port_helper(config);
}
- log_error(LOG_LEVEL_CONNECT, "accept connection ... ");
+ log_error(LOG_LEVEL_CONNECT, "Listening for new connections ... ");
if (!accept_connection(csp, bfd))
{
}
else
{
- log_error(LOG_LEVEL_CONNECT, "OK");
+ log_error(LOG_LEVEL_CONNECT, "accepted connection from %s", csp->ip_addr_str);
}
#ifdef FEATURE_TOGGLE