httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cliff Woolley <jwool...@virginia.edu>
Subject Re: if-modified-since field in request not handled correctly
Date Fri, 03 May 2002 03:25:00 GMT
On 3 May 2002 bugzilla@apache.org wrote:

> There seems to be an error in the handling of If-Modified-Since.
> Steps to reproduce:
> 1. Send the following request to www.dawnorchid.com:
>
> GET / HTTP/1.1
> Host: www.dawnorchid.com
>
> Resulting header is
>
> HTTP/1.1 200 OK
> Date: Sat, 04 May 2002 02:07:27 GMT
> Server: Apache/2.0.35 (Win32) PHP/4.2.0
> Last-Modified: Mon, 29 Apr 2002 07:58:14 GMT
>
> 2. Send another request for the same page, using the above timestamp in an If-
> Modified-Since field.
>
> GET / HTTP/1.1
> Host: www.dawnorchid.com
> If-Modified-Since: Mon, 29 Apr 2002 07:58:14 GMT
>
> Expected result: a 304 Not Modified response.
> Actual result: a 200 OK response with the full HTML page.
>
> If I change the time in the If-Modified-Since field to one second later
> (07:58:15 instead of 07:58:14), the expected 304 Not Modified response is
> returned.


Hmm..  the related code seems to be this snippet from http_protocol.c:

    else if ((r->method_number == M_GET)
             && ((if_modified_since =
                  apr_table_get(r->headers_in,
                                "If-Modified-Since")) != NULL)) {
        apr_time_t ims = apr_date_parse_http(if_modified_since);

        if ((ims >= mtime) && (ims <= r->request_time)) {
            return HTTP_NOT_MODIFIED;
        }
    }
    return OK;


Which *looks* okay.  My best guess is that, since we're comparing
apr_time_t's, maybe mtime includes some number of microseconds and thus is
greater than the ims for the same second.  Does that sound reasonable?  If
so, I guess we need to divide ims, mtime, and r->request_time by
APR_USEC_PER_SEC before comparison.

--Cliff


--------------------------------------------------------------
   Cliff Woolley
   cliffwoolley@yahoo.com
   Charlottesville, VA



Mime
View raw message