Fix spurious 304 error
* tekuti/cache.scm (make-entry): Only return a cached not-modified response if the request was conditional.
This commit is contained in:
parent
7643585d12
commit
e700e4af7a
1 changed files with 14 additions and 10 deletions
|
@ -72,17 +72,21 @@
|
|||
(lambda (request)
|
||||
(and (equal? (request-uri request) uri)
|
||||
(eq? (request-method request) method)
|
||||
(let ((last-modified (response-last-modified response))
|
||||
(let ((request-etags (request-if-none-match request))
|
||||
(since (request-if-modified-since request)))
|
||||
(if (and last-modified since)
|
||||
(time<=? (date->time-utc last-modified)
|
||||
(date->time-utc since))
|
||||
#t))
|
||||
(let ((etag (response-etag response))
|
||||
(match (request-if-none-match request)))
|
||||
(if (and etag match)
|
||||
(and (list? match) (member etag match))
|
||||
#t))
|
||||
(and
|
||||
;; Only return a 304 if the request is conditional.
|
||||
(or request-etags since)
|
||||
;; If the request specifies an etag set, honor it.
|
||||
(or (not request-etags)
|
||||
(and (list? request-etags)
|
||||
(member (response-etag response) request-etags)))
|
||||
;; Likewise for if-modified-since.
|
||||
(or (not since)
|
||||
(let ((last-modified (response-last-modified response)))
|
||||
(and last-modified
|
||||
(time<=? (date->time-utc last-modified)
|
||||
(date->time-utc since)))))))
|
||||
(cons response body))))
|
||||
((200)
|
||||
(lambda (request)
|
||||
|
|
Loading…
Reference in a new issue