-const char jcc_rcs[] = "$Id: jcc.c,v 1.20 2001/06/09 10:55:28 jongfoster Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.21 2001/06/29 13:29:36 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
*
* Revisions :
* $Log: jcc.c,v $
+ * Revision 1.21 2001/06/29 13:29:36 oes
+ * - Cleaned up, improved comments
+ * - Unified all possible interceptors (CGI,
+ * block, trust, fast_redirect) in one
+ * place, with one (CGI) answer generation
+ * mechansim. Much clearer now.
+ * - Removed the GIF image generation, which
+ * is now done in filters.c:block_url()
+ * - Made error conditions like domain lookup
+ * failiure or (various) problems while talking
+ * to the server use cgi.c:error_response()
+ * instead of generating HTML/HTTP in chat() (yuck!)
+ * - Removed logentry from cancelled commit
+ *
* Revision 1.20 2001/06/09 10:55:28 jongfoster
* Changing BUFSIZ ==> BUFFER_SIZE
*
#define IS_ENABLED_AND IS_TOGGLED_ON_AND IS_NOT_FORCED_AND
- char buf[BUFFER_SIZE];\r
+ char buf[BUFFER_SIZE];
char *hdr, *p, *req;
char *err = NULL;
fd_set rfds;
if (
/* a CGI call was detected and answered */
- (NULL != (rsp = dispatch_cgi(csp)))
+ (NULL != (rsp = dispatch_cgi(csp)))
/* or we are enabled and... */
|| (IS_ENABLED_AND (
- /* ..the request was blocked */
- ( NULL != (rsp = block_url(csp)))
+ /* ..the request was blocked */
+ ( NULL != (rsp = block_url(csp)))
/* ..or untrusted */
#ifdef TRUST_FILES
/* ..or a fast redirect kicked in */
#ifdef FAST_REDIRECTS
|| (((csp->action->flags & ACTION_FAST_REDIRECTS) != 0) &&
- (NULL != (rsp = redirect_url(csp))))
+ (NULL != (rsp = redirect_url(csp))))
#endif /* def FAST_REDIRECTS */
- ))
- )
+ ))
+ )
{
- /* Write the answer to the client */
+ /* Write the answer to the client */
if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
- || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
+ || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
{
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
- }
+ }
#ifdef STATISTICS
/* Count as a rejected request */
if (errno == EINVAL)
{
- rsp = error_response(csp, "no-such-domain", errno);
+ rsp = error_response(csp, "no-such-domain", errno);
log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 404 0",
csp->ip_addr_str, http->cmd);
}
else
{
- rsp = error_response(csp, "connect-failed", errno);
+ rsp = error_response(csp, "connect-failed", errno);
log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 503 0",
csp->ip_addr_str, http->cmd);
}
- /* Write the answer to the client */
+ /* Write the answer to the client */
if(rsp)
- {
+ {
if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
- || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
+ || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
{
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
- }
- }
+ }
+ }
free_http_response(rsp);
freez(hdr);
rsp = error_response(csp, "connect-failed", errno);
- if(rsp)
+ if(rsp)
{
if ((write_socket(csp->cfd, rsp->head, n) != n)
- || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
+ || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
{
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
- }
- }
+ }
+ }
free_http_response(rsp);
freez(hdr);
rsp = error_response(csp, "connect-failed", errno);
- if(rsp)
+ if(rsp)
{
if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
- || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
+ || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
{
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
- }
- }
+ }
+ }
free_http_response(rsp);
return;
#ifdef __BEOS__
-
/*********************************************************************
*
* Function : server_thread
return 0;
}
-
#endif