/** * Same as {@link #fromRequestUri(HttpServletRequest)} except the * request is obtained through {@link RequestContextHolder}. */ public static ServletUriComponentsBuilder fromCurrentRequestUri() { return fromRequestUri(getCurrentRequest()); }
/** * Same as {@link #fromRequestUri(HttpServletRequest)} except the * request is obtained through {@link RequestContextHolder}. */ public static ServletUriComponentsBuilder fromCurrentRequestUri() { return fromRequestUri(getCurrentRequest()); }
@Test public void pathExtensionNone() { this.request.setRequestURI("/rest/books/6"); ServletUriComponentsBuilder builder = ServletUriComponentsBuilder.fromRequestUri(this.request); assertNull(builder.removePathExtension()); }
@Test public void fromRequestUri() { this.request.setRequestURI("/mvc-showcase/data/param"); this.request.setQueryString("foo=123"); String result = ServletUriComponentsBuilder.fromRequestUri(this.request).build().toUriString(); assertEquals("http://localhost/mvc-showcase/data/param", result); }
@Test // SPR-10272 public void pathExtension() { this.request.setRequestURI("/rest/books/6.json"); ServletUriComponentsBuilder builder = ServletUriComponentsBuilder.fromRequestUri(this.request); String extension = builder.removePathExtension(); String result = builder.path("/pages/1.{ext}").buildAndExpand(extension).toUriString(); assertEquals("http://localhost/rest/books/6/pages/1.json", result); }
/** * Same as {@link #fromRequestUri(HttpServletRequest)} except the * request is obtained through {@link RequestContextHolder}. * <p><strong>Note:</strong> This method extracts values from "Forwarded" * and "X-Forwarded-*" headers if found. See class-level docs. * <p>As of 4.3.15, this method replaces the contextPath with the value * of "X-Forwarded-Prefix" rather than prepending, thus aligning with * {@code ForwardedHeaderFilter}. */ public static ServletUriComponentsBuilder fromCurrentRequestUri() { return fromRequestUri(getCurrentRequest()); }
HttpServletResponse response ) throws IOException { ServletUriComponentsBuilder builder = ServletUriComponentsBuilder.fromRequestUri(request); String redirectUri = builder.replacePath(pkceProperties.getTokenEndpoint()).build().toUriString();
HttpServletResponse response ) throws IOException { ServletUriComponentsBuilder builder = ServletUriComponentsBuilder.fromRequestUri(request); String redirectUri = builder.replacePath(pkceProperties.getTokenEndpoint()).build().toUriString(); String refererUri = buildRefererUri(targetPath, referer);