Edgewall Software
Modify

Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#9070 closed enhancement (worksforme)

trac.web.api.Request.send_file: test for modification date and If-Modified-Since header

Reported by: Carsten Klein <carsten.klein@…> Owned by:
Priority: normal Milestone:
Component: general Version: 0.12dev
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

here it reads

        stat = os.stat(path)
        mtime = datetime.fromtimestamp(stat.st_mtime, localtz)
        last_modified = http_date(mtime)
        if last_modified == self.get_header('If-Modified-Since'):
            self.send_response(304)
            self.send_header('Content-Length', 0)
            self.end_headers()
            raise RequestDone

should this not be

        if last_modified <= self.get_header('If-Modified-Since'):

?

Attachments (0)

Change History (2)

comment:1 by Remy Blank, 15 years ago

Resolution: worksforme
Status: newclosed

It will not make a difference. If the If-Modified-Since header is present, that means the client has already requested the file before. Then you have one of the following cases:

  • The file has not been modified, and the times are equal, so we don't want to send the file again.
  • The file has been modified, and the client doesn't have the right version. So we want to send the file anyway. In practice, the mtime will always grow, so last_modified will always be greater than the value of the header.

Or in other words: if the header doesn't match the last modification time, the client doesn't have the correct file content, so we want to send it anyway.

comment:2 by Carsten Klein <carsten.klein@…>, 15 years ago

never thought of it in that way, thanks for the input

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.