1
0
Fork 0

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:
Andy Wingo 2016-08-28 10:58:34 +02:00
parent 7643585d12
commit e700e4af7a

View file

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