# Currently unused.  This is how to return the appropriate header to an
# upstream cache to avoid fetching, w/o Expires or Cache-Control.
# However, you have to get modDate in a way that takes all of the page
# elements into account.

def checkNotMod(self, modDate, REQUEST, RESPONSE):
    """
    If REQUEST contains an If-Modifed-Since header, and modDate is not
    after that date, set the appropriate status on RESPONSE and return
    true, else return None.
    """
    # ripped from ImageFile.py
    header=REQUEST.get_header('If-Modified-Since', None)
    if header is not None:
        header=string.split(header, ';')[0]
        # Some proxies seem to send invalid date strings for this
        # header. If the date string is not valid, we ignore it
        # rather than raise an error to be generally consistent
        # with common servers such as Apache (which can usually
        # understand the screwy date string as a lucky side effect
        # of the way they parse it).
        try:    mod_since = DateTime(header)
        except: mod_since = None
        if mod_since is not None and modDate <= mod_since:
            RESPONSE.setStatus(304)
            return 1
        return None
