FacadeHostRequestWrapper extends HttpServletRequestWrapper { public static String buildFacadeUrl(String url, String contextPath, String documentrHost) { contextPath = StringUtils.defaultIfBlank(contextPath, StringUtils.EMPTY); if (contextPath.equals("/")) { contextPath = StringUtils.EMPTY; } String newUrl; if (StringUtils.isNotBlank(contextPath)) { int pos = url.indexOf(contextPath); newUrl = documentrHost + url.substring(pos + contextPath.length()); } else { UriComponentsBuilder builder; try { builder = UriComponentsBuilder.fromHttpUrl(url); } catch (IllegalArgumentException e) { builder = UriComponentsBuilder.fromUriString(url); } String path = StringUtils.defaultIfBlank( builder.build().getPath(), StringUtils.EMPTY); if (StringUtils.isNotBlank(path)) { int pos = StringUtils.lastIndexOf(url, path); newUrl = documentrHost + url.substring(pos); } else { newUrl = documentrHost; } } return newUrl; } FacadeHostRequestWrapper(HttpServletRequest request, String documentrHost); @Override StringBuffer getRequestURL(); static String buildFacadeUrl(String url, String contextPath, String documentrHost);  }
@Test @SuppressWarnings("nls") public void buildFacadeUrl() { assertEquals("https: "http: assertEquals("https: "http: assertEquals("https: "http: assertEquals("https: "http: assertEquals("https: "http: assertEquals("https: "http: assertEquals("https: "http: }