-const char parsers_rcs[] = "$Id: parsers.c,v 1.267 2012/11/24 14:06:18 fabiankeil Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.271 2012/12/07 12:50:17 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/parsers.c,v $
{ "Request-Range:", 14, client_range },
{ "If-Range:", 9, client_range },
{ "X-Filter:", 9, client_x_filter },
+#if 0
+ { "Transfer-Encoding:", 18, client_transfer_encoding },
+#endif
{ "*", 0, crunch_client_header },
{ "*", 0, filter_header },
{ NULL, 0, NULL }
log_error(LOG_LEVEL_HEADER,
"Content modified with no Content-Length header set. "
"Created: %s.", header);
+ csp->flags |= CSP_FLAG_SERVER_CONTENT_LENGTH_SET;
}
}
#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
+/*********************************************************************
+ *
+ * Function : client_transfer_encoding
+ *
+ * Description : Raise the CSP_FLAG_CHUNKED_CLIENT_BODY flag if
+ * the request body is "chunked"
+ *
+ * XXX: Currently not called through sed() as we
+ * need the flag earlier on. Should be fixed.
+ *
+ * Parameters :
+ * 1 : csp = Current client state (buffers, headers, etc...)
+ * 2 : header = On input, pointer to header to modify.
+ * On output, pointer to the modified header, or NULL
+ * to remove the header. This function frees the
+ * original string if necessary.
+ *
+ * Returns : JB_ERR_OK on success, or
+ *
+ *********************************************************************/
+jb_err client_transfer_encoding(struct client_state *csp, char **header)
+{
+ if (strstr(*header, "chunked"))
+ {
+ csp->flags |= CSP_FLAG_CHUNKED_CLIENT_BODY;
+ log_error(LOG_LEVEL_HEADER, "Expecting chunked client body");
+ }
+
+ return JB_ERR_OK;
+}
+
+
/*********************************************************************
*
* Function : crumble
{
log_error(LOG_LEVEL_FATAL, "Invalid cookie lifetime limit: %s", param);
}
- cookie_lifetime *= 60U;
+ cookie_lifetime *= 60;
}
/* Loop through each tag in the cookie */
continue;
}
*result = timegm(&gmt);
+
+#ifdef FEATURE_STRPTIME_SANITY_CHECKS
+ /*
+ * Verify that parsing the date recreated from the first
+ * parse operation gets the previous result. If it doesn't,
+ * either strptime() or strftime() are malfunctioning.
+ *
+ * We could string-compare the recreated date with the original
+ * header date, but this leads to false positives as strptime()
+ * may let %a accept all day formats while strftime() will only
+ * create one.
+ */
+ {
+ char recreated_date[100];
+ struct tm *tm;
+ time_t result2;
+
+ tm = gmtime(result);
+ strftime(recreated_date, sizeof(recreated_date), time_formats[i], tm);
+ memset(&gmt, 0, sizeof(gmt));
+ if (NULL == strptime(recreated_date, time_formats[i], &gmt))
+ {
+ log_error(LOG_LEVEL_ERROR,
+ "Failed to parse '%s' generated with '%s' to recreate '%s'.",
+ recreated_date, time_formats[i], header_time);
+ continue;
+ }
+ result2 = timegm(&gmt);
+ if (*result != result2)
+ {
+ log_error(LOG_LEVEL_ERROR, "strftime() and strptime() disagree. "
+ "Format: '%s'. In: '%s', out: '%s'. %d != %d. Rejecting.",
+ time_formats[i], header_time, recreated_date, *result, result2);
+ continue;
+ }
+ }
+#endif
+
return JB_ERR_OK;
}
}