diff options
author | wollman <wollman@FreeBSD.org> | 1999-01-15 16:56:22 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 1999-01-15 16:56:22 +0000 |
commit | 78818f4318a345f6c7a93e4c01d1f2db8b21e617 (patch) | |
tree | 57f28c1306eab6350bdaf04e8f1a22c93e8341f3 /usr.bin/fetch/http.c | |
parent | 9db9503e47722d70e22614dadc691e2c419a6ede (diff) | |
download | FreeBSD-src-78818f4318a345f6c7a93e4c01d1f2db8b21e617.zip FreeBSD-src-78818f4318a345f6c7a93e4c01d1f2db8b21e617.tar.gz |
For RFC 850 dates received in HTTP responses, implement the century pivot
described in RFC 2068. Include a reference to same in the manual page.
Diffstat (limited to 'usr.bin/fetch/http.c')
-rw-r--r-- | usr.bin/fetch/http.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/usr.bin/fetch/http.c b/usr.bin/fetch/http.c index ff8d25f..6d3fe26 100644 --- a/usr.bin/fetch/http.c +++ b/usr.bin/fetch/http.c @@ -26,7 +26,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: http.c,v 1.21 1998/10/26 02:39:21 fenner Exp $ + * $Id: http.c,v 1.22 1998/12/08 13:00:49 cracauer Exp $ */ #include <sys/types.h> @@ -1394,6 +1394,14 @@ parse_http_date(char *string) tm.tm_year = i - 1900; } else { /* Monday, 27-Jan-97 14:31:09 stuffwedon'tcareabout */ + /* Quoth RFC 2068: + o HTTP/1.1 clients and caches should assume that an RFC-850 date + which appears to be more than 50 years in the future is in fact + in the past (this helps solve the "year 2000" problem). + */ + time_t now; + struct tm *tmnow; + int this2dyear; char *comma = strchr(string, ','); char mname[4]; @@ -1415,6 +1423,14 @@ parse_http_date(char *string) if (i >= 12) return -1; tm.tm_mon = i; + /* + * RFC 2068 year interpretation. + */ + time(&now); + tmnow = gmtime(&now); + this2dyear = tmnow->tm_year % 100; + if (tm.tm_year - this2dyear >= 50) + tm.tm_year += 100; } #undef digit |