3232 * UriComponentsBuilder with additional static factory methods to create links
3333 * based on the current HttpServletRequest.
3434 *
35- * <p><strong>Note:</strong> This class uses values from "Forwarded"
36- * (<a href="http://tools.ietf.org/html/rfc7239">RFC 7239</a>),
37- * "X-Forwarded-Host", "X-Forwarded-Port", and "X-Forwarded-Proto" headers,
38- * if present, in order to reflect the client-originated protocol and address.
39- * Consider using the {@code ForwardedHeaderFilter} in order to choose from a
40- * central place whether to extract and use, or to discard such headers.
41- * See the Spring Framework reference for more on this filter.
35+ * <p><strong>Note:</strong> As of 5.1, methods in this class do not extract
36+ * {@code "Forwarded"} and {@code "X-Forwarded-*"} headers that specify the
37+ * client-originated address. Please, use
38+ * {@link org.springframework.web.filter.ForwardedHeaderFilter
39+ * ForwardedHeaderFilter}, or similar from the underlying server, to extract
40+ * and use such headers, or to discard them.
4241 *
4342 * @author Rossen Stoyanchev
4443 * @since 3.1
@@ -76,10 +75,6 @@ protected ServletUriComponentsBuilder(ServletUriComponentsBuilder other) {
7675 /**
7776 * Prepare a builder from the host, port, scheme, and context path of the
7877 * given HttpServletRequest.
79- * <p><strong>Note:</strong> As of 5.1, this method ignores
80- * {@code "Forwarded"} and {@code "X-Forwarded-*"} headers that specify the
81- * client-originated address. Consider using the {@code ForwardedHeaderFilter}
82- * to extract and use, or to discard such headers.
8378 */
8479 public static ServletUriComponentsBuilder fromContextPath (HttpServletRequest request ) {
8580 ServletUriComponentsBuilder builder = initFromRequest (request );
@@ -94,10 +89,6 @@ public static ServletUriComponentsBuilder fromContextPath(HttpServletRequest req
9489 * will end with "/main". If the servlet is mapped otherwise, e.g.
9590 * {@code "/"} or {@code "*.do"}, the result will be the same as
9691 * if calling {@link #fromContextPath(HttpServletRequest)}.
97- * <p><strong>Note:</strong> As of 5.1, this method ignores
98- * {@code "Forwarded"} and {@code "X-Forwarded-*"} headers that specify the
99- * client-originated address. Consider using the {@code ForwardedHeaderFilter}
100- * to extract and use, or to discard such headers.
10192 */
10293 public static ServletUriComponentsBuilder fromServletMapping (HttpServletRequest request ) {
10394 ServletUriComponentsBuilder builder = fromContextPath (request );
@@ -110,10 +101,6 @@ public static ServletUriComponentsBuilder fromServletMapping(HttpServletRequest
110101 /**
111102 * Prepare a builder from the host, port, scheme, and path (but not the query)
112103 * of the HttpServletRequest.
113- * <p><strong>Note:</strong> As of 5.1, this method ignores
114- * {@code "Forwarded"} and {@code "X-Forwarded-*"} headers that specify the
115- * client-originated address. Consider using the {@code ForwardedHeaderFilter}
116- * to extract and use, or to discard such headers.
117104 */
118105 public static ServletUriComponentsBuilder fromRequestUri (HttpServletRequest request ) {
119106 ServletUriComponentsBuilder builder = initFromRequest (request );
@@ -124,10 +111,6 @@ public static ServletUriComponentsBuilder fromRequestUri(HttpServletRequest requ
124111 /**
125112 * Prepare a builder by copying the scheme, host, port, path, and
126113 * query string of an HttpServletRequest.
127- * <p><strong>Note:</strong> As of 5.1, this method ignores
128- * {@code "Forwarded"} and {@code "X-Forwarded-*"} headers that specify the
129- * client-originated address. Consider using the {@code ForwardedHeaderFilter}
130- * to extract and use, or to discard such headers.
131114 */
132115 public static ServletUriComponentsBuilder fromRequest (HttpServletRequest request ) {
133116 ServletUriComponentsBuilder builder = initFromRequest (request );
@@ -159,11 +142,6 @@ private static ServletUriComponentsBuilder initFromRequest(HttpServletRequest re
159142 /**
160143 * Same as {@link #fromContextPath(HttpServletRequest)} except the
161144 * request is obtained through {@link RequestContextHolder}.
162- * <p><strong>Note:</strong> This method extracts values from "Forwarded"
163- * and "X-Forwarded-*" headers if found. See class-level docs.
164- * <p>As of 4.3.15, this method replaces the contextPath with the value
165- * of "X-Forwarded-Prefix" rather than prepending, thus aligning with
166- * {@code ForwardedHeaderFilter}.
167145 */
168146 public static ServletUriComponentsBuilder fromCurrentContextPath () {
169147 return fromContextPath (getCurrentRequest ());
@@ -172,11 +150,6 @@ public static ServletUriComponentsBuilder fromCurrentContextPath() {
172150 /**
173151 * Same as {@link #fromServletMapping(HttpServletRequest)} except the
174152 * request is obtained through {@link RequestContextHolder}.
175- * <p><strong>Note:</strong> This method extracts values from "Forwarded"
176- * and "X-Forwarded-*" headers if found. See class-level docs.
177- * <p>As of 4.3.15, this method replaces the contextPath with the value
178- * of "X-Forwarded-Prefix" rather than prepending, thus aligning with
179- * {@code ForwardedHeaderFilter}.
180153 */
181154 public static ServletUriComponentsBuilder fromCurrentServletMapping () {
182155 return fromServletMapping (getCurrentRequest ());
@@ -185,11 +158,6 @@ public static ServletUriComponentsBuilder fromCurrentServletMapping() {
185158 /**
186159 * Same as {@link #fromRequestUri(HttpServletRequest)} except the
187160 * request is obtained through {@link RequestContextHolder}.
188- * <p><strong>Note:</strong> This method extracts values from "Forwarded"
189- * and "X-Forwarded-*" headers if found. See class-level docs.
190- * <p>As of 4.3.15, this method replaces the contextPath with the value
191- * of "X-Forwarded-Prefix" rather than prepending, thus aligning with
192- * {@code ForwardedHeaderFilter}.
193161 */
194162 public static ServletUriComponentsBuilder fromCurrentRequestUri () {
195163 return fromRequestUri (getCurrentRequest ());
@@ -198,11 +166,6 @@ public static ServletUriComponentsBuilder fromCurrentRequestUri() {
198166 /**
199167 * Same as {@link #fromRequest(HttpServletRequest)} except the
200168 * request is obtained through {@link RequestContextHolder}.
201- * <p><strong>Note:</strong> This method extracts values from "Forwarded"
202- * and "X-Forwarded-*" headers if found. See class-level docs.
203- * <p>As of 4.3.15, this method replaces the contextPath with the value
204- * of "X-Forwarded-Prefix" rather than prepending, thus aligning with
205- * {@code ForwardedHeaderFilter}.
206169 */
207170 public static ServletUriComponentsBuilder fromCurrentRequest () {
208171 return fromRequest (getCurrentRequest ());
0 commit comments