Index: modules/http/http_protocol.c =================================================================== --- modules/http/http_protocol.c (revision 1373281) +++ modules/http/http_protocol.c (working copy) @@ -299,9 +299,10 @@ /* All of our comparisons must be in seconds, because that's the * highest time resolution the HTTP specification allows. */ - /* XXX: we should define a "time unset" constant */ - tmp_time = ((r->mtime != 0) ? r->mtime : apr_time_now()); - mtime = apr_time_sec(tmp_time); + /* XXX: we should define a "time unset" constant + * XXX: meanwhile we interpret 0 as unset + */ + mtime = apr_time_sec(r->mtime); /* If an If-Match request-header field was given * AND the field value is not "*" (meaning match anything) @@ -325,7 +326,8 @@ if (if_unmodified != NULL) { apr_time_t ius = apr_date_parse_http(if_unmodified); - if ((ius != APR_DATE_BAD) && (mtime > apr_time_sec(ius))) { + if ((ius != APR_DATE_BAD) + && (mtime == 0 || mtime > apr_time_sec(ius))) { return HTTP_PRECONDITION_FAILED; } } @@ -376,6 +378,7 @@ * A date later than the server's current request time is invalid. */ if (r->method_number == M_GET + && (mtime != 0) && (not_modified || !if_nonematch) && (if_modified_since = apr_table_get(r->headers_in, @@ -384,10 +387,13 @@ apr_int64_t ims, reqtime; ims_time = apr_date_parse_http(if_modified_since); - ims = apr_time_sec(ims_time); - reqtime = apr_time_sec(r->request_time); - not_modified = ims >= mtime && ims <= reqtime; + if (ims_time != APR_DATE_BAD) { + ims = apr_time_sec(ims_time); + reqtime = apr_time_sec(r->request_time); + + not_modified = ims >= mtime && ims <= reqtime; + } } if (not_modified) {