You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Lukasz Lenart (JIRA)" <ji...@apache.org> on 2012/09/06 14:23:08 UTC
[jira] [Updated] (WW-3492) DefaultHttpHeaders does not handle
last-modified and if-modified-since requests correctly
[ https://issues.apache.org/jira/browse/WW-3492?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Lukasz Lenart updated WW-3492:
------------------------------
Fix Version/s: (was: 2.3.x)
2.3.6
> 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
> Fix For: 2.3.6
>
>
> 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.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira