summaryrefslogtreecommitdiffstats
path: root/usr.bin/fetch
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>1999-01-15 16:56:22 +0000
committerwollman <wollman@FreeBSD.org>1999-01-15 16:56:22 +0000
commit78818f4318a345f6c7a93e4c01d1f2db8b21e617 (patch)
tree57f28c1306eab6350bdaf04e8f1a22c93e8341f3 /usr.bin/fetch
parent9db9503e47722d70e22614dadc691e2c419a6ede (diff)
downloadFreeBSD-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')
-rw-r--r--usr.bin/fetch/fetch.134
-rw-r--r--usr.bin/fetch/http.c18
2 files changed, 48 insertions, 4 deletions
diff --git a/usr.bin/fetch/fetch.1 b/usr.bin/fetch/fetch.1
index ccbc80c..f3be659 100644
--- a/usr.bin/fetch/fetch.1
+++ b/usr.bin/fetch/fetch.1
@@ -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
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
OpenPOWER on IntegriCloud