You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Gordon McNaughton (JIRA)" <ji...@apache.org> on 2010/09/08 03:52:32 UTC

[jira] Created: (WW-3492) DefaultHttpHeaders does not handle last-modified and if-modified-since requests correctly

DefaultHttpHeaders does not handle last-modified and if-modified-since requests correctly
-----------------------------------------------------------------------------------------

                 Key: WW-3492
                 URL: https://issues.apache.org/jira/browse/WW-3492
             Project: Struts 2
          Issue Type: Bug
          Components: Plugin - REST
    Affects Versions: 2.1.8.1
            Reporter: Gordon McNaughton
            Priority: Minor


1.  Create a controller method that creates a DefaultHttpHeaders object, then calls lastModified(...).withNoETag()
2.  Hit the method in a browser; verify that the response contains a "Last-Modified" header and no "ETag" header
3.  Refresh the browser
4.  Verify that the browser request contains an "If-Modified-Since" header with the same date
5.  Look at the http response code

What happens?
The controller returns a 200 OK instead of a 304 Not Modified, so the browser can't use its cache.

DefaultHttpHeaders has code (DefaultHttpHeaders.java ln 132) that tries to determine whether the last modified date matches the "If-Modified-Since" header.  However, it does so by making a string comparison between the header string ("Tue Sep 07 16:34:08 PDT 2010") and a number of milliseconds ("112345..."), which is going to fail.

I worked around this by adding custom code to the controller that compares lastModified and If-Modified-Since, and calls withStatus(HttpServletResponse.SC_NOT_MODIFIED) if appropriate, but it would be cleaner if DefaultHttpHeaders handled this automatically (as it is obviously trying to do).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.