#509 - Polishing.

Formatting and author note.

Original pull request: #519.
This commit is contained in:
Oliver Gierke
2016-12-07 16:56:07 +01:00
parent 47cefe6869
commit 327e2cda76
2 changed files with 28 additions and 27 deletions

View File

@@ -15,11 +15,11 @@
*/
package org.springframework.hateoas.mvc;
import static org.springframework.util.StringUtils.*;
import lombok.RequiredArgsConstructor;
import lombok.experimental.Delegate;
import static org.springframework.util.StringUtils.hasText;
import java.lang.reflect.Method;
import java.net.URI;
import java.util.Map;
@@ -32,7 +32,7 @@ import org.springframework.hateoas.core.AnnotationMappingDiscoverer;
import org.springframework.hateoas.core.DummyInvocationUtils;
import org.springframework.hateoas.core.LinkBuilderSupport;
import org.springframework.hateoas.core.MappingDiscoverer;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.util.Assert;
import org.springframework.util.ConcurrentReferenceHashMap;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -53,7 +53,7 @@ import org.springframework.web.util.UriTemplate;
* @author Greg Turnquist
* @author Kevin Conaway
* @author Andrew Naydyonock
* @author Oliver Trosien
* @author Oliver Trosien
*/
public class ControllerLinkBuilder extends LinkBuilderSupport<ControllerLinkBuilder> {
@@ -255,29 +255,29 @@ public class ControllerLinkBuilder extends LinkBuilderSupport<ControllerLinkBuil
}
/**
* Returns a {@link UriComponentsBuilder} obtained from the current servlet mapping with
* scheme tweaked in case the request contains an {@code X-Forwarded-Ssl} header, which is not (yet)
* supported by the underlying {@link UriComponentsBuilder}.
* Returns a {@link UriComponentsBuilder} obtained from the current servlet mapping with scheme tweaked in case the
* request contains an {@code X-Forwarded-Ssl} header, which is not (yet) supported by the underlying
* {@link UriComponentsBuilder}.
*
* @return
*/
static UriComponentsBuilder getBuilder() {
HttpServletRequest request = getCurrentRequest();
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpRequest(new ServletServerHttpRequest(request));
// special case handling for X-Forwarded-Ssl:
// apply it, but only if X-Forwarded-Proto is unset.
String forwardedSsl = request.getHeader("X-Forwarded-Ssl");
ForwardedHeader forwarded = ForwardedHeader.of(request.getHeader(ForwardedHeader.NAME));
String proto = hasText(forwarded.getProto()) ? forwarded.getProto() : request.getHeader("X-Forwarded-Proto");
if (!hasText(proto) && hasText(forwardedSsl) && forwardedSsl.equalsIgnoreCase("on")) {
builder.scheme("https");
}
return builder;
HttpServletRequest request = getCurrentRequest();
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpRequest(new ServletServerHttpRequest(request));
// special case handling for X-Forwarded-Ssl:
// apply it, but only if X-Forwarded-Proto is unset.
String forwardedSsl = request.getHeader("X-Forwarded-Ssl");
ForwardedHeader forwarded = ForwardedHeader.of(request.getHeader(ForwardedHeader.NAME));
String proto = hasText(forwarded.getProto()) ? forwarded.getProto() : request.getHeader("X-Forwarded-Proto");
if (!hasText(proto) && hasText(forwardedSsl) && forwardedSsl.equalsIgnoreCase("on")) {
builder.scheme("https");
}
return builder;
}
/**