-const char cgi_rcs[] = "$Id: cgi.c,v 1.90 2007/01/25 13:47:26 fabiankeil Exp $";
+const char cgi_rcs[] = "$Id: cgi.c,v 1.91 2007/01/27 13:09:16 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/cgi.c,v $
*
* Revisions :
* $Log: cgi.c,v $
+ * Revision 1.91 2007/01/27 13:09:16 fabiankeil
+ * Add new config option "templdir" to
+ * change the templates directory.
+ *
* Revision 1.90 2007/01/25 13:47:26 fabiankeil
* Added "forwarding-failed" template support for error_response().
*
if (!err)
{
/* It worked */
- return finish_http_response(rsp);
+ return finish_http_response(csp, rsp);
}
else
{
return cgi_error_memory();
}
- return finish_http_response(rsp);
+ return finish_http_response(csp, rsp);
}
"\r\n";
cgi_error_memory_response->body =
"<html>\r\n"
- "<head><title>500 Internal Privoxy Error</title></head>\r\n"
+ "<head>\r\n"
+ " <title>500 Internal Privoxy Error</title>\r\n"
+ " <link rel=\"shortcut icon\" href=\"" CGI_PREFIX "error-favicon.ico\" type=\"image/x-icon\">"
+ "</head>\r\n"
"<body>\r\n"
"<h1>500 Internal Privoxy Error</h1>\r\n"
"<p>Privoxy <b>ran out of memory</b> while processing your request.</p>\r\n"
"500 Internal Privoxy Error";
static const char body_prefix[] =
"<html>\r\n"
- "<head><title>500 Internal Privoxy Error</title></head>\r\n"
+ "<head>\r\n"
+ " <title>500 Internal Privoxy Error</title>\r\n"
+ " <link rel=\"shortcut icon\" href=\"" CGI_PREFIX "error-favicon.ico\" type=\"image/x-icon\">"
+ "</head>\r\n"
"<body>\r\n"
"<h1>500 Internal Privoxy Error</h1>\r\n"
"<p>Privoxy encountered an error while processing your request:</p>\r\n"
"500 Internal Privoxy Error";
static const char body_prefix[] =
"<html>\r\n"
- "<head><title>500 Internal Privoxy Error</title></head>\r\n"
+ "<head>\r\n"
+ " <title>500 Internal Privoxy Error</title>\r\n"
+ " <link rel=\"shortcut icon\" href=\"" CGI_PREFIX "error-favicon.ico\" type=\"image/x-icon\">"
+ "</head>\r\n"
"<body>\r\n"
"<h1>500 Internal Privoxy Error</h1>\r\n"
"<p>Privoxy encountered an error while processing your request:</p>\r\n"
*
* Description : Fill in the missing headers in an http response,
* and flatten the headers to an http head.
+ * For HEAD requests the body is freed once
+ * the Content-Length header is set.
*
* Parameters :
* 1 : rsp = pointer to http_response to be processed
* On error, free()s rsp and returns cgi_error_memory()
*
*********************************************************************/
-struct http_response *finish_http_response(struct http_response *rsp)
+struct http_response *finish_http_response(const struct client_state *csp, struct http_response *rsp)
{
char buf[BUFFER_SIZE];
jb_err err;
err = enlist(rsp->headers, buf);
}
- if (strncmpic(rsp->status, "302", 3))
+ if (0 == strcmpic(csp->http->gpc, "head"))
+ {
+ /*
+ * The client only asked for the head. Dispose
+ * the body and log an offensive message.
+ *
+ * While it may seem to be a bit inefficient to
+ * prepare the body if it isn't needed, it's the
+ * only way to get the Content-Length right for
+ * dynamic pages. We could have disposed the body
+ * earlier, but not without duplicating the
+ * Content-Length setting code above.
+ */
+ log_error(LOG_LEVEL_CGI, "Preparing to give head to %s.", csp->ip_addr_str);
+ freez(rsp->body);
+ rsp->content_length = 0;
+ }
+
+ if ((rsp->status != NULL) && strncmpic(rsp->status, "302", 3))
{
/*
* If it's not a redirect without any content,
#ifndef CGI_H_INCLUDED
#define CGI_H_INCLUDED
-#define CGI_H_VERSION "$Id: cgi.h,v 1.31 2006/07/18 14:48:45 david__schmidt Exp $"
+#define CGI_H_VERSION "$Id: cgi.h,v 1.32 2006/12/17 17:53:39 fabiankeil Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/cgi.h,v $
* Functions declared include:
*
*
- * 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: cgi.h,v $
+ * Revision 1.32 2006/12/17 17:53:39 fabiankeil
+ * Suppress the toggle link if remote toggling is disabled.
+ *
* Revision 1.31 2006/07/18 14:48:45 david__schmidt
* Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch)
* with what was really the latest development (the v_3_0_branch branch)
extern struct http_response * alloc_http_response(void);
extern void free_http_response(struct http_response *rsp);
-extern struct http_response *finish_http_response(struct http_response *rsp);
+extern struct http_response *finish_http_response(const struct client_state *csp,
+ struct http_response *rsp);
extern struct map * default_exports(const struct client_state *csp, const char *caller);
-const char filters_rcs[] = "$Id: filters.c,v 1.76 2007/01/01 19:36:37 fabiankeil Exp $";
+const char filters_rcs[] = "$Id: filters.c,v 1.77 2007/01/12 15:36:44 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/filters.c,v $
*
* Revisions :
* $Log: filters.c,v $
+ * Revision 1.77 2007/01/12 15:36:44 fabiankeil
+ * Mark *csp as immutable for is_untrusted_url()
+ * and is_imageurl(). Closes FR 1237736.
+ *
* Revision 1.76 2007/01/01 19:36:37 fabiankeil
* Integrate a modified version of Wil Mahan's
* zlib patch (PR #895531).
}
}
- return finish_http_response(rsp);
+ return finish_http_response(csp, rsp);
}
return cgi_error_memory();
}
- return finish_http_response(rsp);
+ return finish_http_response(csp, rsp);
}
#endif /* def FEATURE_TRUST */
return cgi_error_memory();
}
freez(new_url);
- return finish_http_response(rsp);
+ return finish_http_response(csp, rsp);
}
}
}
rsp->is_static = 1;
- return(finish_http_response(rsp));
+ return(finish_http_response(csp, rsp));
}
}
}