Was something modified since the user last downloaded it? header This is the value of the If-Modified-Since header. If this is None, I'll just return True. mtime This is the modification time of the item we're talking about.
(header=None, mtime=0)
| 101 | |
| 102 | |
| 103 | def was_modified_since(header=None, mtime=0): |
| 104 | """ |
| 105 | Was something modified since the user last downloaded it? |
| 106 | |
| 107 | header |
| 108 | This is the value of the If-Modified-Since header. If this is None, |
| 109 | I'll just return True. |
| 110 | |
| 111 | mtime |
| 112 | This is the modification time of the item we're talking about. |
| 113 | """ |
| 114 | try: |
| 115 | if header is None: |
| 116 | raise ValueError |
| 117 | header_mtime = parse_http_date(header) |
| 118 | if int(mtime) > header_mtime: |
| 119 | raise ValueError |
| 120 | except (ValueError, OverflowError): |
| 121 | return True |
| 122 | return False |