use of javax.servlet.http.HttpServletRequest in project tomcat by apache.
the class TestExpiresFilter method testUseDefaultConfiguration1.
@Test
public void testUseDefaultConfiguration1() 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.getWriter().print("Hello world");
}
};
validate(servlet, Integer.valueOf(1 * 60));
}
use of javax.servlet.http.HttpServletRequest in project tomcat by apache.
the class TestExpiresFilter method testUseContentTypeWithoutCharsetExpiresConfiguration.
@Test
public void testUseContentTypeWithoutCharsetExpiresConfiguration() 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=iso-8859-1");
response.getWriter().print("Hello world");
}
};
validate(servlet, Integer.valueOf(5 * 60));
}
use of javax.servlet.http.HttpServletRequest in project tomcat by apache.
the class TestExpiresFilter method testUseContentTypeExpiresConfiguration.
@Test
public void testUseContentTypeExpiresConfiguration() 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.getWriter().print("Hello world");
}
};
validate(servlet, Integer.valueOf(3 * 60));
}
use of javax.servlet.http.HttpServletRequest in project tomcat by apache.
the class TestExpiresFilter method testUseMajorTypeExpiresConfiguration.
@Test
public void testUseMajorTypeExpiresConfiguration() 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/json; charset=iso-8859-1");
response.getWriter().print("Hello world");
}
};
validate(servlet, Integer.valueOf(7 * 60));
}
use of javax.servlet.http.HttpServletRequest in project zeppelin by apache.
the class CorsFilter method doFilter.
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
String sourceHost = ((HttpServletRequest) request).getHeader("Origin");
String origin = "";
try {
if (SecurityUtils.isValidOrigin(sourceHost, ZeppelinConfiguration.create())) {
origin = sourceHost;
}
} catch (URISyntaxException e) {
LOGGER.error("Exception in WebDriverManager while getWebDriver ", e);
}
if (((HttpServletRequest) request).getMethod().equals("OPTIONS")) {
HttpServletResponse resp = ((HttpServletResponse) response);
addCorsHeaders(resp, origin);
return;
}
if (response instanceof HttpServletResponse) {
HttpServletResponse alteredResponse = ((HttpServletResponse) response);
addCorsHeaders(alteredResponse, origin);
}
filterChain.doFilter(request, response);
}
Aggregations