[Registry-dev] svn commit r11784 -
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet
svn at wso2.org
svn at wso2.org
Wed Jan 2 22:41:19 PST 2008
Author: chathura
Date: Wed Jan 2 22:41:15 2008
New Revision: 11784
Log:
Implemented the support for If-Modified-Since header. Now the requests to the /resources path returns
304 response, if the modified time is not expired.
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java Wed Jan 2 22:41:15 2008
@@ -229,6 +229,15 @@
return;
}
+ // handle if-modified-since header
+ long modifiedSince = request.getDateHeader("If-Modified-Since");
+ if (modifiedSince > 0 && resource.getLastModified().getTime() >= modifiedSince) {
+ response.setStatus(304);
+ response.getWriter().flush();
+ return;
+ }
+
+
if (resource.isDirectory()) {
response.sendRedirect("/wso2registry/web" + path);
} else {
@@ -295,6 +304,8 @@
Object content = resource.getContent();
if (content != null) {
+ response.setDateHeader("Last-Modified", resource.getLastModified().getTime());
+
if (resource.getMediaType() != null && resource.getMediaType().length() > 0) {
response.setContentType(resource.getMediaType());
} else {
More information about the Registry-dev
mailing list