-const char jcc_rcs[] = "$Id: jcc.c,v 1.114 2006/12/27 18:52:02 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.117 2006/12/31 17:56:37 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
*
* Revisions :
* $Log: jcc.c,v $
+ * Revision 1.117 2006/12/31 17:56:37 fabiankeil
+ * Added config option accept-intercepted-requests
+ * and disabled it by default.
+ *
+ * Revision 1.116 2006/12/29 19:08:22 fabiankeil
+ * Reverted parts of my last commit
+ * to keep error handling working.
+ *
+ * Revision 1.115 2006/12/29 17:38:57 fabiankeil
+ * Fixed gcc43 conversion warnings.
+ *
* Revision 1.114 2006/12/27 18:52:02 fabiankeil
* Fix -pedantic ISO C warning about converting
* from function pointer to object pointer.
int max_forwarded_connect_retries = csp->config->forwarded_connect_retries;
const struct forward_spec * fwd;
struct http_request *http;
- size_t len; /* for buffer sizes */
+ int len; /* for buffer sizes (and negative error codes) */
#ifdef FEATURE_KILL_POPUPS
int block_popups; /* bool, 1==will block popups */
int block_popups_now = 0; /* bool, 1==currently blocking popups */
{
/*
* Intercepted or invalid request without domain
- * inside the request line. Try to get it another way.
+ * inside the request line. Try to get it another way,
+ * unless accept-intercepted-requests is disabled.
*/
- if (JB_ERR_OK == get_destination_from_headers(headers, http))
+ if (!(csp->config->feature_flags & RUNTIME_FEATURE_ACCEPT_INTERCEPTED_REQUESTS))
+ {
+ log_error(LOG_LEVEL_ERROR, "%s's request: \'%s\' is invalid."
+ " Privoxy isn't configured to accept intercepted requests.",
+ csp->ip_addr_str, http->cmd);
+ log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 400 0", csp->ip_addr_str, http->cmd);
+
+ strcpy(buf, CHEADER);
+ write_socket(csp->cfd, buf, strlen(buf));
+ free_http_request(http);
+ destroy_list(headers);
+ return;
+ }
+ else if (JB_ERR_OK == get_destination_from_headers(headers, http))
{
/* Split the domain we just got for pattern matching */
init_domain_components(http);
* Let's pretend the server just sent us a blank line.
*/
snprintf(buf, sizeof(buf), "\r\n");
- len = strlen(buf);
+ len = (int)strlen(buf);
/*
* Now, let the normal header parsing algorithm below do its
if (write_socket(csp->cfd, hdr, hdrlen)
|| ((flushed = flush_socket(csp->cfd, csp)) < 0)
- || (write_socket(csp->cfd, buf, len)))
+ || (write_socket(csp->cfd, buf, (size_t)len)))
{
log_error(LOG_LEVEL_CONNECT, "Flush header and buffers to client failed: %E");
return;
}
- byte_count += hdrlen + (size_t)flushed + len;
+ byte_count += hdrlen + (size_t)(flushed + len);
freez(hdr);
content_filter = NULL;
server_body = 1;
}
else
{
- if (write_socket(csp->cfd, buf, len))
+ if (write_socket(csp->cfd, buf, (size_t)len))
{
log_error(LOG_LEVEL_ERROR, "write to client failed: %E");
return;
}
}
- byte_count += len;
+ byte_count += (size_t)len;
continue;
}
else
*/
if (write_socket(csp->cfd, hdr, strlen(hdr))
- || ((len = (size_t)flush_socket(csp->cfd, csp)) < 0))
+ || ((len = flush_socket(csp->cfd, csp)) < 0))
{
log_error(LOG_LEVEL_CONNECT, "write header to client failed: %E");
return;
}
- byte_count += len;
+ byte_count += (size_t)len;
}
/* we're finished with the server's header */
#define SELECTED_ONE_OPTION
csp->cfd = ReleaseSocket(csp->cfd, -1);
- if((child_id = (int)CreateNewProcTags(
- NP_Entry, (ULONG)server_thread,
- NP_Output, Output(),
- NP_CloseOutput, FALSE,
- NP_Name, (ULONG)"privoxy child",
- NP_StackSize, 200*1024,
- TAG_DONE)))
+#ifdef __amigaos4__
+ child_id = (int)CreateNewProcTags(NP_Entry, (ULONG)server_thread,
+ NP_Output, Output(),
+ NP_CloseOutput, FALSE,
+ NP_Name, (ULONG)"privoxy child",
+ NP_Child, TRUE,
+ TAG_DONE);
+#else
+ child_id = (int)CreateNewProcTags(NP_Entry, (ULONG)server_thread,
+ NP_Output, Output(),
+ NP_CloseOutput, FALSE,
+ NP_Name, (ULONG)"privoxy child",
+ NP_StackSize, 200*1024,
+ TAG_DONE);
+#endif
+ if(0 != child_id)
{
childs++;
((struct Task *)child_id)->tc_UserData = csp;