-const char parsers_rcs[] = "$Id: parsers.c,v 1.6 2001/05/26 13:39:32 jongfoster Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.7 2001/05/27 13:19:06 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/parsers.c,v $
*
* Revisions :
* $Log: parsers.c,v $
+ * Revision 1.7 2001/05/27 13:19:06 oes
+ * Patched Joergs solution for the content-length in.
+ *
* Revision 1.6 2001/05/26 13:39:32 jongfoster
* Only crunches Content-Length header if applying RE filtering.
* Without this fix, Microsoft Windows Update wouldn't work.
{
for (p = csp->headers->next; p ; p = p->next)
{
+ /* Header crunch()ed in previous run? -> ignore */
+ if (p->str == NULL) continue;
+
if (v == pats) log_error(LOG_LEVEL_HEADER, "scan: %s", p->str);
- if (p->str == NULL)
- {
- /* hit me */
- log_error(LOG_LEVEL_ERROR, "NULL header");
- }
- else if (strncmpic(p->str, v->str, v->len) == 0)
+ if (strncmpic(p->str, v->str, v->len) == 0)
{
hdr = v->parser(v, p->str, csp);
freez(p->str);
(*f)(csp);
}
- /* add the blank line at the end of the header */
- enlist(csp->headers, "");
+ /* add the blank line at the end of the header, if necessary */
+ if(strlen(csp->headers->last->str) != 0)
+ {
+ enlist(csp->headers, "");
+ }
hdr = list_to_text(csp->headers);
*********************************************************************/
char *content_length(const struct parsers *v, char *s, struct client_state *csp)
{
- if (((csp->permissions & PERMIT_RE_FILTER) != 0) && csp->is_text)
- {
- log_error(LOG_LEVEL_HEADER, "crunch!");
- return(NULL);
- }
+ if (csp->content_length != 0) /* Content has been modified */
+ {
+ s = (char *) zalloc(100);
+ snprintf(s, 100, "Content-Length: %d", csp->content_length);
+ log_error(LOG_LEVEL_HEADER, "Adjust Content-Length to %d", csp->content_length);
+ return(s);
+ }
else
{
return(strdup(s));