HADOOP-6607. Add different variants of non caching HTTP headers. (tucu)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1409921 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8a2de21315
commit
ce2067fb15
|
@ -431,6 +431,8 @@ Release 2.0.3-alpha - Unreleased
|
||||||
|
|
||||||
HADOOP-8999. SASL negotiation is flawed (daryn)
|
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
|
Release 2.0.2-alpha - 2012-09-07
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -25,7 +25,12 @@ import java.net.BindException;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.security.GeneralSecurityException;
|
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.net.ssl.SSLServerSocketFactory;
|
||||||
import javax.servlet.Filter;
|
import javax.servlet.Filter;
|
||||||
|
|
|
@ -38,6 +38,10 @@ public class NoCacheFilter implements Filter {
|
||||||
throws IOException, ServletException {
|
throws IOException, ServletException {
|
||||||
HttpServletResponse httpRes = (HttpServletResponse) res;
|
HttpServletResponse httpRes = (HttpServletResponse) res;
|
||||||
httpRes.setHeader("Cache-Control", "no-cache");
|
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);
|
chain.doFilter(req, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -546,6 +546,10 @@ public class TestHttpServer extends HttpServerFunctionalTest {
|
||||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());
|
assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());
|
||||||
assertEquals("no-cache", conn.getHeaderField("Cache-Control"));
|
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"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue