-const char jcc_rcs[] = "$Id: jcc.c,v 1.379 2012/07/23 12:39:12 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.386 2012/07/27 17:41:42 fabiankeil 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-2010 the
+ * Copyright : Written by and Copyright (C) 2001-2012 the
* Privoxy team. http://www.privoxy.org/
*
* Based on the Internet Junkbuster originally written
}
+/*********************************************************************
+ *
+ * Function : log_applied_actions
+ *
+ * Description : Logs the applied actions if LOG_LEVEL_ACTIONS is
+ * enabled.
+ *
+ * Parameters :
+ * 1 : actions = Current action spec to log
+ *
+ * Returns : Nothing.
+ *
+ *********************************************************************/
+static void log_applied_actions(const struct current_action_spec *actions)
+{
+ /*
+ * The conversion to text requires lots of memory allocations so
+ * we only do the conversion if the user is actually interested.
+ */
+ if (debug_level_is_enabled(LOG_LEVEL_ACTIONS))
+ {
+ char *actions_as_text = actions_to_line_of_text(actions);
+ log_error(LOG_LEVEL_ACTIONS, "%s", actions_as_text);
+ freez(actions_as_text);
+ }
+}
+
+
/*********************************************************************
*
* Function : send_crunch_response
status_code[3] = '\0';
/* Log that the request was crunched and why. */
+ log_applied_actions(csp->action);
log_error(LOG_LEVEL_CRUNCH, "%s: %s", crunch_reason(rsp), http->url);
log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" %s %u",
csp->ip_addr_str, http->ocmd, status_code, rsp->content_length);
/* Assume persistence until further notice */
csp->flags |= CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE;
}
+
+ if (csp->http->ssl == 0)
+ {
+ csp->expected_client_content_length = get_expected_content_length(csp->headers);
+ verify_request_length(csp);
+ }
#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
err = sed(csp, FILTER_CLIENT_HEADERS);
return JB_ERR_PARSE;
}
-#ifdef FEATURE_CONNECTION_KEEP_ALIVE
- if (csp->http->ssl == 0)
- {
- verify_request_length(csp);
- }
-#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
-
return JB_ERR_OK;
}
return;
}
+ log_applied_actions(csp->action);
log_error(LOG_LEVEL_GPC, "%s%s", http->hostport, http->path);
if (fwd->forward_host)
if (csp->cfd != JB_INVALID_SOCKET)
{
+ log_error(LOG_LEVEL_CONNECT, "Closing client socket %d. "
+ "Keep-alive: %u, Socket alive: %u. Data available: %u.",
+ csp->cfd, 0 != (csp->flags & CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE),
+ socket_is_still_alive(csp->cfd), data_is_available(csp->cfd, 0));
close_socket(csp->cfd);
}
basedir = strdup_or_die(cwd);
/* XXX: why + 5? */
abs_file_size = strlen(cwd) + strlen(configfile) + 5;
- abs_file = malloc(abs_file_size);
- if (NULL == abs_file)
- {
- perror("malloc failed");
- exit(1);
- }
+ abs_file = malloc_or_die(abs_file_size);
strlcpy(abs_file, basedir, abs_file_size);
strlcat(abs_file, "/", abs_file_size);
strlcat(abs_file, configfile, abs_file_size);