List of usage examples for org.apache.hadoop.http HtmlQuoting quoteHtmlChars
public static String quoteHtmlChars(String item)
From source file:org.apache.atlas.web.filters.ActiveServerFilter.java
License:Apache License
private void handleRedirect(HttpServletRequest servletRequest, HttpServletResponse httpServletResponse, String activeServerAddress) throws IOException { HttpServletRequest httpServletRequest = servletRequest; String requestURI = httpServletRequest.getRequestURI(); String queryString = httpServletRequest.getQueryString(); if ((queryString != null) && (!queryString.isEmpty())) { requestURI += "?" + queryString; }// w w w. ja va 2 s.c om String quotedUri = HtmlQuoting.quoteHtmlChars(requestURI); if (quotedUri == null) { quotedUri = "/"; } String redirectLocation = activeServerAddress + quotedUri; LOG.info("Not active. Redirecting to {}", redirectLocation); // A POST/PUT/DELETE require special handling by sending HTTP 307 instead of the regular 301/302. // Reference: http://stackoverflow.com/questions/2068418/whats-the-difference-between-a-302-and-a-307-redirect if (isUnsafeHttpMethod(httpServletRequest)) { httpServletResponse.setHeader(HttpHeaders.LOCATION, redirectLocation); httpServletResponse.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT); } else { httpServletResponse.sendRedirect(redirectLocation); } }