diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index e2b1d66a6a4..5689ae0d848 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -431,6 +431,8 @@ Release 2.0.3-alpha - Unreleased HADOOP-8999. SASL negotiation is flawed (daryn) + HADOOP-6607. Add different variants of non caching HTTP headers. (tucu) + Release 2.0.2-alpha - 2012-09-07 INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer.java index 683ccf4125c..ea768ab75a6 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer.java @@ -25,7 +25,12 @@ import java.net.BindException; import java.net.InetSocketAddress; import java.net.URL; import java.security.GeneralSecurityException; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import javax.net.ssl.SSLServerSocketFactory; import javax.servlet.Filter; @@ -960,7 +965,7 @@ public class HttpServer implements FilterContainer { @Override public Enumeration getParameterNames() { return new Enumeration() { - private Enumeration rawIterator = + private Enumeration rawIterator = rawRequest.getParameterNames(); @Override public boolean hasMoreElements() { diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/NoCacheFilter.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/NoCacheFilter.java index 6c3397f3c93..54a101b8b83 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/NoCacheFilter.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/NoCacheFilter.java @@ -38,6 +38,10 @@ public class NoCacheFilter implements Filter { throws IOException, ServletException { HttpServletResponse httpRes = (HttpServletResponse) res; httpRes.setHeader("Cache-Control", "no-cache"); + long now = System.currentTimeMillis(); + httpRes.addDateHeader("Expires", now); + httpRes.addDateHeader("Date", now); + httpRes.addHeader("Pragma", "no-cache"); chain.doFilter(req, res); } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java index e78fc4b53fc..acbf8918bfc 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java @@ -546,6 +546,10 @@ public class TestHttpServer extends HttpServerFunctionalTest { HttpURLConnection conn = (HttpURLConnection) url.openConnection(); assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode()); assertEquals("no-cache", conn.getHeaderField("Cache-Control")); + assertEquals("no-cache", conn.getHeaderField("Pragma")); + assertNotNull(conn.getHeaderField("Expires")); + assertNotNull(conn.getHeaderField("Date")); + assertEquals(conn.getHeaderField("Expires"), conn.getHeaderField("Date")); } }