|
15 | 15 | */
|
16 | 16 | package org.springframework.hateoas.mvc;
|
17 | 17 |
|
| 18 | +import static org.springframework.util.StringUtils.*; |
| 19 | + |
18 | 20 | import lombok.RequiredArgsConstructor;
|
19 | 21 | import lombok.experimental.Delegate;
|
20 | 22 |
|
21 |
| -import static org.springframework.util.StringUtils.hasText; |
22 |
| - |
23 | 23 | import java.lang.reflect.Method;
|
24 | 24 | import java.net.URI;
|
25 | 25 | import java.util.Map;
|
|
32 | 32 | import org.springframework.hateoas.core.DummyInvocationUtils;
|
33 | 33 | import org.springframework.hateoas.core.LinkBuilderSupport;
|
34 | 34 | import org.springframework.hateoas.core.MappingDiscoverer;
|
35 |
| -import org.springframework.http.server.ServletServerHttpRequest; |
| 35 | +import org.springframework.http.server.ServletServerHttpRequest; |
36 | 36 | import org.springframework.util.Assert;
|
37 | 37 | import org.springframework.util.ConcurrentReferenceHashMap;
|
38 | 38 | import org.springframework.web.bind.annotation.RequestMapping;
|
|
53 | 53 | * @author Greg Turnquist
|
54 | 54 | * @author Kevin Conaway
|
55 | 55 | * @author Andrew Naydyonock
|
56 |
| - * @author Oliver Trosien |
| 56 | + * @author Oliver Trosien |
57 | 57 | */
|
58 | 58 | public class ControllerLinkBuilder extends LinkBuilderSupport<ControllerLinkBuilder> {
|
59 | 59 |
|
@@ -255,29 +255,29 @@ public String toString() {
|
255 | 255 | }
|
256 | 256 |
|
257 | 257 | /**
|
258 |
| - * Returns a {@link UriComponentsBuilder} obtained from the current servlet mapping with |
259 |
| - * scheme tweaked in case the request contains an {@code X-Forwarded-Ssl} header, which is not (yet) |
260 |
| - * supported by the underlying {@link UriComponentsBuilder}. |
| 258 | + * Returns a {@link UriComponentsBuilder} obtained from the current servlet mapping with scheme tweaked in case the |
| 259 | + * request contains an {@code X-Forwarded-Ssl} header, which is not (yet) supported by the underlying |
| 260 | + * {@link UriComponentsBuilder}. |
261 | 261 | *
|
262 | 262 | * @return
|
263 | 263 | */
|
264 | 264 | static UriComponentsBuilder getBuilder() {
|
265 |
| - |
266 |
| - HttpServletRequest request = getCurrentRequest(); |
267 |
| - UriComponentsBuilder builder = UriComponentsBuilder.fromHttpRequest(new ServletServerHttpRequest(request)); |
268 |
| - |
269 |
| - // special case handling for X-Forwarded-Ssl: |
270 |
| - // apply it, but only if X-Forwarded-Proto is unset. |
271 |
| - |
272 |
| - String forwardedSsl = request.getHeader("X-Forwarded-Ssl"); |
273 |
| - ForwardedHeader forwarded = ForwardedHeader.of(request.getHeader(ForwardedHeader.NAME)); |
274 |
| - String proto = hasText(forwarded.getProto()) ? forwarded.getProto() : request.getHeader("X-Forwarded-Proto"); |
275 |
| - |
276 |
| - if (!hasText(proto) && hasText(forwardedSsl) && forwardedSsl.equalsIgnoreCase("on")) { |
277 |
| - builder.scheme("https"); |
278 |
| - } |
279 |
| - |
280 |
| - return builder; |
| 265 | + |
| 266 | + HttpServletRequest request = getCurrentRequest(); |
| 267 | + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpRequest(new ServletServerHttpRequest(request)); |
| 268 | + |
| 269 | + // special case handling for X-Forwarded-Ssl: |
| 270 | + // apply it, but only if X-Forwarded-Proto is unset. |
| 271 | + |
| 272 | + String forwardedSsl = request.getHeader("X-Forwarded-Ssl"); |
| 273 | + ForwardedHeader forwarded = ForwardedHeader.of(request.getHeader(ForwardedHeader.NAME)); |
| 274 | + String proto = hasText(forwarded.getProto()) ? forwarded.getProto() : request.getHeader("X-Forwarded-Proto"); |
| 275 | + |
| 276 | + if (!hasText(proto) && hasText(forwardedSsl) && forwardedSsl.equalsIgnoreCase("on")) { |
| 277 | + builder.scheme("https"); |
| 278 | + } |
| 279 | + |
| 280 | + return builder; |
281 | 281 | }
|
282 | 282 |
|
283 | 283 | /**
|
|
0 commit comments