like 2.0/2.2/trunk
I'm looking for a conceptual +1 out there.
I've barely tested it and need to summarize the diffs between ap_ and
apr_ functions again. (e.g., "apr_date_parse_http supports format XXX
that ap_parseHTTPdate() doesn't support, but ap_proxy_date_canon()
didn't allow that before anyway so it doesn't regress...")
--
Born in Roswell... married an alien...
Index: src/modules/proxy/proxy_util.c
===================================================================
--- src/modules/proxy/proxy_util.c (revision 586541)
+++ src/modules/proxy/proxy_util.c (working copy)
@@ -267,61 +267,17 @@
* formatted, then it exits very quickly.
*/
const char *
- ap_proxy_date_canon(pool *p, const char *x)
+ ap_proxy_date_canon(pool *p, const char *date)
{
- int wk, mday, year, hour, min, sec, mon;
- char *q, month[4], zone[4], week[4];
+ time_t t;
- q = strchr(x, ',');
- /* check for RFC 850 date */
- if (q != NULL && q - x > 3 && q[1] == ' ') {
- *q = '\0';
- for (wk = 0; wk < 7; wk++)
- if (strcmp(x, lwday[wk]) == 0)
- break;
- *q = ',';
- if (wk == 7)
- return x; /* not a valid date */
- if (q[4] != '-' || q[8] != '-' || q[11] != ' ' || q[14] != ':' ||
- q[17] != ':' || strcmp(&q[20], " GMT") != 0)
- return x;
- if (sscanf(q + 2, "%u-%3s-%u %u:%u:%u %3s", &mday, month, &year,
- &hour, &min, &sec, zone) != 7)
- return x;
- if (year < 70)
- year += 2000;
- else
- year += 1900;
+ t = ap_parseHTTPdate(date);
+ if (t == BAD_DATE) {
+ return date;
}
- else {
-/* check for acstime() date */
- if (x[3] != ' ' || x[7] != ' ' || x[10] != ' ' || x[13] != ':' ||
- x[16] != ':' || x[19] != ' ' || x[24] != '\0')
- return x;
- if (sscanf(x, "%3s %3s %u %u:%u:%u %u", week, month, &mday, &hour,
- &min, &sec, &year) != 7)
- return x;
- for (wk = 0; wk < 7; wk++)
- if (strcmp(week, ap_day_snames[wk]) == 0)
- break;
- if (wk == 7)
- return x;
- }
-
-/* check date */
- for (mon = 0; mon < 12; mon++)
- if (strcmp(month, ap_month_snames[mon]) == 0)
- break;
- if (mon == 12)
- return x;
-
- q = ap_palloc(p, 30);
- ap_snprintf(q, 30, "%s, %.2d %s %d %.2d:%.2d:%.2d GMT", ap_day_snames[wk],
mday,
- ap_month_snames[mon], year, hour, min, sec);
- return q;
+ return ap_gm_timestr_822(p, t);
}
-
/*
* Reads headers from a buffer and returns an array of headers.
* Returns NULL on file error