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.
This commit is contained in:
Garrett Wollman 1999-01-15 16:56:22 +00:00
parent 82bbdcdaed
commit c146843096
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=42702
2 changed files with 48 additions and 4 deletions

View File

@ -1,7 +1,7 @@
.\" $Id: fetch.1,v 1.25 1998/11/08 23:18:47 des Exp $
.Dd July 2, 1996
.\" $Id: fetch.1,v 1.26 1998/12/08 13:00:48 cracauer Exp $
.Dd January 15, 1999
.Dt FETCH 1
.Os FreeBSD 2.2
.Os FreeBSD 3.1
.Sh NAME
.Nm fetch
.Nd retrieve a file by Uniform Resource Locator
@ -316,6 +316,16 @@ connection.
.Sh SEE ALSO
.Xr ftp 1 ,
.Xr tftp 1
.Rs
.%A R. Fielding
.%A J. Gettys
.%A J. Mogul
.%A H. Frystyk
.%A T. Berners-Lee
.%T "Hypertext Transfer Protocol \-\- HTTP/1.1"
.%O RFC 2068
.%D January 1997
.Re
.Sh HISTORY
The
.Nm fetch
@ -371,3 +381,21 @@ and
.Fl b
involves a minimum of two round trips (for small replies), one less than
other implementations.
.Pp
The
.Tn HTTP
standard requires interpretation of the
.Tn RFC 850
date format, which does not provide a century indication. Versions of
.Nm fetch
prior to
.Fx 3.1
would interpret all such dates as being in the 1900s. This version of
.Nm fetch
interprets such dates according to the rule given in
.Tn RFC 2068 :
.Bd -literal -offset indent
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).
.Ed

View File

@ -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