From dcbcd94db89a8e73ebc3089a860575bbeb8d1708 Mon Sep 17 00:00:00 2001 From: Daniel Hartwig Date: Sun, 27 Nov 2011 18:25:55 +0800 Subject: [PATCH] Permit non-date values for "Expires" header. * module/web/http.scm ("Expires"): Permit non-date values. --- module/web/http.scm | 20 +++++++++++++++++++- test-suite/tests/web-http.test | 1 + 2 files changed, 20 insertions(+), 1 deletions(-) diff --git a/module/web/http.scm b/module/web/http.scm index dc742a1..5eb2e90 100644 --- a/module/web/http.scm +++ b/module/web/http.scm @@ -1500,7 +1500,25 @@ phrase\"." ;; Expires = HTTP-date ;; -(declare-date-header! "Expires") +;; ... +;; HTTP/1.1 clients and caches MUST treat other invalid date formats, +;; especially including the value "0", as in the past (i.e., "already +;; expired"). +;; +(declare-header! "Expires" + (lambda (str) + (or (false-if-exception (parse-date str)) + str)) + (lambda (val) + (or (string? val) (date? val))) + (lambda (val port) + (cond + ((string? val) + (display val port)) + ((date? val) + (write-date val port)) + (else + (bad-header-component 'expires val))))) ;; Last-Modified = HTTP-date ;; diff --git a/test-suite/tests/web-http.test b/test-suite/tests/web-http.test index b6abbf3..c881223 100644 --- a/test-suite/tests/web-http.test +++ b/test-suite/tests/web-http.test @@ -134,6 +134,7 @@ (pass-if-parse expires "Tue, 15 Nov 1994 08:12:31 GMT" (string->date "Tue, 15 Nov 1994 08:12:31 +0000" "~a, ~d ~b ~Y ~H:~M:~S ~z")) + (pass-if-parse expires "0" "0") (pass-if-parse last-modified "Tue, 15 Nov 1994 08:12:31 GMT" (string->date "Tue, 15 Nov 1994 08:12:31 +0000" "~a, ~d ~b ~Y ~H:~M:~S ~z"))) -- 1.7.2.5