use of jakarta.servlet.http.HttpServletResponse in project tomcat by apache.
the class TestExpiresFilter method testSkipBecauseExpiresIsDefined.
@Test
public void testSkipBecauseExpiresIsDefined() throws Exception {
HttpServlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/xml; charset=utf-8");
response.addDateHeader("Expires", System.currentTimeMillis());
response.getWriter().print("Hello world");
}
};
validate(servlet, null);
}
use of jakarta.servlet.http.HttpServletResponse in project tomcat by apache.
the class TestExpiresFilter method testUseDefaultConfiguration2.
@Test
public void testUseDefaultConfiguration2() throws Exception {
HttpServlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("image/jpeg");
response.addHeader("Cache-Control", "private");
response.getWriter().print("Hello world");
}
};
validate(servlet, Integer.valueOf(1 * 60));
}
use of jakarta.servlet.http.HttpServletResponse in project tomcat by apache.
the class TestExpiresFilter method testEmptyContent.
/*
* Test that a resource with empty content is also processed
*/
@Test
public void testEmptyContent() throws Exception {
HttpServlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/plain");
// no content is written in the response
}
};
validate(servlet, Integer.valueOf(7 * 60));
}
use of jakarta.servlet.http.HttpServletResponse in project tomcat by apache.
the class TestExpiresFilter method testNullContentType.
@Test
public void testNullContentType() throws Exception {
HttpServlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(null);
}
};
validate(servlet, Integer.valueOf(1 * 60));
}
use of jakarta.servlet.http.HttpServletResponse in project tomcat by apache.
the class TestExpiresFilter method testSkipBecauseCacheControlMaxAgeIsDefined.
@Test
public void testSkipBecauseCacheControlMaxAgeIsDefined() throws Exception {
HttpServlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/xml; charset=utf-8");
response.addHeader("Cache-Control", "private, max-age=232");
response.getWriter().print("Hello world");
}
};
validate(servlet, Integer.valueOf(232));
}
Aggregations