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 {

_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev

Reply via email to