﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
37487	Conditional request handling treats the Unix epoch as a missing date	canblmz	canblmz	"`parse_http_date_safe()` returns `0` for `Thu, 01 Jan 1970 00:00:00 GMT`, and the conditional request code checks these timestamps for truthiness, so the epoch is handled as if the date were missing:

 * `get_conditional_response()` ignores `If-Unmodified-Since: Thu, 01 Jan 1970 00:00:00 GMT`, so a request that should get 412 (for any resource modified after 1970) goes through.
 * `_if_unmodified_since_passes()` and `_if_modified_since_passes()` treat a resource whose `Last-Modified` is the epoch as having no modification date: `If-Unmodified-Since` always gives 412, and `If-Modified-Since` never gives 304.
 * `ConditionalGetMiddleware` passes an epoch `Last-Modified` on as missing, and skips conditional handling altogether when the response has no `ETag`.
 * `@condition` / `@last_modified` don't add the `Last-Modified` header when `last_modified_func` returns the epoch.

An epoch `Last-Modified` can come up for files whose mtime was normalized to 0, e.g. by a reproducible build.

Comparing with `is None` / `is not None` instead fixes all four. I have a patch with tests ready.

This touches the same helper as #37252 ([https://github.com/django/django/pull/21737 PR 21737]), where `not last_modified` would also treat the epoch as missing. The two fixes are compatible, and I'm happy to rebase on whichever lands first."	Bug	assigned	HTTP handling	dev	Normal				Unreviewed	0	0	0	0	0	0
