--- /dev/null
+// NoCacheFilter.java\r
+// $Id: NoCacheFilter.java,v 1.1 2010/06/15 12:24:58 smhuang Exp $\r
+// (c) COPYRIGHT MIT, INRIA and Keio, 1999.\r
+// Please first read the full copyright statement in file COPYRIGHT.html\r
+\r
+package org.w3c.jigsaw.filters;\r
+\r
+import org.w3c.tools.resources.ProtocolException;\r
+import org.w3c.tools.resources.ReplyInterface;\r
+import org.w3c.tools.resources.RequestInterface;\r
+import org.w3c.tools.resources.ResourceFilter;\r
+\r
+import org.w3c.tools.resources.ProtocolException;\r
+\r
+import org.w3c.www.http.HttpMessage;\r
+\r
+import org.w3c.jigsaw.http.Request;\r
+\r
+/**\r
+ * Transform a Pragma: no-cache into a Cache-Control: max-age=0\r
+ * It is just here to fix some client brokenness.\r
+ */\r
+\r
+public class NoCacheFilter extends ResourceFilter {\r
+\r
+ /**\r
+ * Modify the request to transform a Pragma: no-cache into a \r
+ * Cache-Control: max-age=0\r
+ * @return A Reply instance, if the filter did know how to answer\r
+ * the request without further processing, <strong>null</strong> \r
+ * otherwise. \r
+ * @exception ProtocolException If processing should be interrupted,\r
+ * because an abnormal situation occured. \r
+ */ \r
+ public ReplyInterface ingoingFilter(RequestInterface request) \r
+ throws ProtocolException\r
+ {\r
+ Request req = (Request) request;\r
+ if (req.hasPragma("no-cache")) {\r
+ String pragmas[] = req.getPragma();\r
+ if (pragmas.length == 1) {\r
+ req.setPragma(null);\r
+ } else {\r
+ // remove the no-cache\r
+ String newpragmas[] = new String[pragmas.length - 1];\r
+ for (int i=0, j=0; i<pragmas.length; i++) {\r
+ if (pragmas[i].equals("no-cache"))\r
+ continue;\r
+ newpragmas[j++] = pragmas[i];\r
+ }\r
+ req.setPragma(newpragmas);\r
+ }\r
+ req.setMaxAge(0);\r
+ }\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ * The outgoing filter decorates the reply appropriately.\r
+ * @param request The original request.\r
+ * @param reply The originial reply.\r
+ * @return Always <strong>null</strong>.\r
+ * @exception ProtocolException If processing should be interrupted,\r
+ * because an abnormal situation occured. \r
+ */\r
+\r
+ public ReplyInterface outgoingFilter(RequestInterface req,\r
+ ReplyInterface rep) \r
+ throws ProtocolException\r
+ {\r
+ return null;\r
+ }\r
+}\r