|
|
|
|
@ -31,7 +31,6 @@ import org.springframework.http.HttpRequest;
@@ -31,7 +31,6 @@ import org.springframework.http.HttpRequest;
|
|
|
|
|
import org.springframework.http.server.ServletServerHttpRequest; |
|
|
|
|
import org.springframework.util.LinkedMultiValueMap; |
|
|
|
|
import org.springframework.util.MultiValueMap; |
|
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
import org.springframework.web.testfixture.servlet.MockHttpServletRequest; |
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
|
@ -48,10 +47,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
@@ -48,10 +47,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
|
|
|
|
* @author Sam Brannen |
|
|
|
|
* @author David Eckel |
|
|
|
|
*/ |
|
|
|
|
public class UriComponentsBuilderTests { |
|
|
|
|
class UriComponentsBuilderTests { |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void plain() throws URISyntaxException { |
|
|
|
|
void plain() throws URISyntaxException { |
|
|
|
|
UriComponentsBuilder builder = UriComponentsBuilder.newInstance(); |
|
|
|
|
UriComponents result = builder.scheme("https").host("example.com") |
|
|
|
|
.path("foo").queryParam("bar").fragment("baz") |
|
|
|
|
@ -67,7 +66,7 @@ public class UriComponentsBuilderTests {
@@ -67,7 +66,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void multipleFromSameBuilder() throws URISyntaxException { |
|
|
|
|
void multipleFromSameBuilder() throws URISyntaxException { |
|
|
|
|
UriComponentsBuilder builder = UriComponentsBuilder.newInstance() |
|
|
|
|
.scheme("https").host("example.com").pathSegment("foo"); |
|
|
|
|
UriComponents result1 = builder.build(); |
|
|
|
|
@ -90,7 +89,7 @@ public class UriComponentsBuilderTests {
@@ -90,7 +89,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void fromPath() throws URISyntaxException { |
|
|
|
|
void fromPath() throws URISyntaxException { |
|
|
|
|
UriComponents result = UriComponentsBuilder.fromPath("foo").queryParam("bar").fragment("baz").build(); |
|
|
|
|
assertThat(result.getPath()).isEqualTo("foo"); |
|
|
|
|
assertThat(result.getQuery()).isEqualTo("bar"); |
|
|
|
|
@ -109,7 +108,7 @@ public class UriComponentsBuilderTests {
@@ -109,7 +108,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void fromHierarchicalUri() throws URISyntaxException { |
|
|
|
|
void fromHierarchicalUri() throws URISyntaxException { |
|
|
|
|
URI uri = new URI("https://example.com/foo?bar#baz"); |
|
|
|
|
UriComponents result = UriComponentsBuilder.fromUri(uri).build(); |
|
|
|
|
assertThat(result.getScheme()).isEqualTo("https"); |
|
|
|
|
@ -122,7 +121,7 @@ public class UriComponentsBuilderTests {
@@ -122,7 +121,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void fromOpaqueUri() throws URISyntaxException { |
|
|
|
|
void fromOpaqueUri() throws URISyntaxException { |
|
|
|
|
URI uri = new URI("mailto:foo@bar.com#baz"); |
|
|
|
|
UriComponents result = UriComponentsBuilder.fromUri(uri).build(); |
|
|
|
|
assertThat(result.getScheme()).isEqualTo("mailto"); |
|
|
|
|
@ -133,7 +132,7 @@ public class UriComponentsBuilderTests {
@@ -133,7 +132,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-9317
|
|
|
|
|
public void fromUriEncodedQuery() throws URISyntaxException { |
|
|
|
|
void fromUriEncodedQuery() throws URISyntaxException { |
|
|
|
|
URI uri = new URI("https://www.example.org/?param=aGVsbG9Xb3JsZA%3D%3D"); |
|
|
|
|
String fromUri = UriComponentsBuilder.fromUri(uri).build().getQueryParams().get("param").get(0); |
|
|
|
|
String fromUriString = UriComponentsBuilder.fromUriString(uri.toString()) |
|
|
|
|
@ -143,7 +142,7 @@ public class UriComponentsBuilderTests {
@@ -143,7 +142,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void fromUriString() { |
|
|
|
|
void fromUriString() { |
|
|
|
|
UriComponents result = UriComponentsBuilder.fromUriString("https://www.ietf.org/rfc/rfc3986.txt").build(); |
|
|
|
|
assertThat(result.getScheme()).isEqualTo("https"); |
|
|
|
|
assertThat(result.getUserInfo()).isNull(); |
|
|
|
|
@ -189,7 +188,7 @@ public class UriComponentsBuilderTests {
@@ -189,7 +188,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-9832
|
|
|
|
|
public void fromUriStringQueryParamWithReservedCharInValue() { |
|
|
|
|
void fromUriStringQueryParamWithReservedCharInValue() { |
|
|
|
|
String uri = "https://www.google.com/ig/calculator?q=1USD=?EUR"; |
|
|
|
|
UriComponents result = UriComponentsBuilder.fromUriString(uri).build(); |
|
|
|
|
|
|
|
|
|
@ -198,27 +197,15 @@ public class UriComponentsBuilderTests {
@@ -198,27 +197,15 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-14828
|
|
|
|
|
public void fromUriStringQueryParamEncodedAndContainingPlus() { |
|
|
|
|
void fromUriStringQueryParamEncodedAndContainingPlus() { |
|
|
|
|
String httpUrl = "http://localhost:8080/test/print?value=%EA%B0%80+%EB%82%98"; |
|
|
|
|
URI uri = UriComponentsBuilder.fromHttpUrl(httpUrl).build(true).toUri(); |
|
|
|
|
URI uri = UriComponentsBuilder.fromUriString(httpUrl).build(true).toUri(); |
|
|
|
|
|
|
|
|
|
assertThat(uri.toString()).isEqualTo(httpUrl); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-10779
|
|
|
|
|
public void fromHttpUrlStringCaseInsesitiveScheme() { |
|
|
|
|
assertThat(UriComponentsBuilder.fromHttpUrl("HTTP://www.google.com").build().getScheme()).isEqualTo("http"); |
|
|
|
|
assertThat(UriComponentsBuilder.fromHttpUrl("HTTPS://www.google.com").build().getScheme()).isEqualTo("https"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-10539
|
|
|
|
|
public void fromHttpUrlStringInvalidIPv6Host() { |
|
|
|
|
assertThatIllegalArgumentException().isThrownBy(() -> |
|
|
|
|
UriComponentsBuilder.fromHttpUrl("http://[1abc:2abc:3abc::5ABC:6abc:8080/resource").build().encode()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-10539
|
|
|
|
|
public void fromUriStringIPv6Host() { |
|
|
|
|
void fromUriStringIPv6Host() { |
|
|
|
|
UriComponents result = UriComponentsBuilder |
|
|
|
|
.fromUriString("http://[1abc:2abc:3abc::5ABC:6abc]:8080/resource").build().encode(); |
|
|
|
|
assertThat(result.getHost()).isEqualTo("[1abc:2abc:3abc::5ABC:6abc]"); |
|
|
|
|
@ -233,16 +220,114 @@ public class UriComponentsBuilderTests {
@@ -233,16 +220,114 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-11970
|
|
|
|
|
public void fromUriStringNoPathWithReservedCharInQuery() { |
|
|
|
|
void fromUriStringNoPathWithReservedCharInQuery() { |
|
|
|
|
UriComponents result = UriComponentsBuilder.fromUriString("https://example.com?foo=bar@baz").build(); |
|
|
|
|
assertThat(StringUtils.isEmpty(result.getUserInfo())).isTrue(); |
|
|
|
|
assertThat(result.getUserInfo()).isNull(); |
|
|
|
|
assertThat(result.getHost()).isEqualTo("example.com"); |
|
|
|
|
assertThat(result.getQueryParams().containsKey("foo")).isTrue(); |
|
|
|
|
assertThat(result.getQueryParams()).containsKey("foo"); |
|
|
|
|
assertThat(result.getQueryParams().getFirst("foo")).isEqualTo("bar@baz"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-14828
|
|
|
|
|
void fromHttpUrlQueryParamEncodedAndContainingPlus() { |
|
|
|
|
String httpUrl = "http://localhost:8080/test/print?value=%EA%B0%80+%EB%82%98"; |
|
|
|
|
URI uri = UriComponentsBuilder.fromHttpUrl(httpUrl).build(true).toUri(); |
|
|
|
|
|
|
|
|
|
assertThat(uri.toString()).isEqualTo(httpUrl); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-10779
|
|
|
|
|
void fromHttpUrlCaseInsensitiveScheme() { |
|
|
|
|
assertThat(UriComponentsBuilder.fromHttpUrl("HTTP://www.google.com").build().getScheme()).isEqualTo("http"); |
|
|
|
|
assertThat(UriComponentsBuilder.fromHttpUrl("HTTPS://www.google.com").build().getScheme()).isEqualTo("https"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-10539
|
|
|
|
|
void fromHttpUrlInvalidIPv6Host() { |
|
|
|
|
assertThatIllegalArgumentException().isThrownBy(() -> |
|
|
|
|
UriComponentsBuilder.fromHttpUrl("http://[1abc:2abc:3abc::5ABC:6abc:8080/resource")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void fromHttpRequest() { |
|
|
|
|
void fromHttpUrlWithoutFragment() { |
|
|
|
|
String httpUrl = "http://localhost:8080/test/print"; |
|
|
|
|
UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl(httpUrl).build(); |
|
|
|
|
assertThat(uriComponents.getScheme()).isEqualTo("http"); |
|
|
|
|
assertThat(uriComponents.getUserInfo()).isNull(); |
|
|
|
|
assertThat(uriComponents.getHost()).isEqualTo("localhost"); |
|
|
|
|
assertThat(uriComponents.getPort()).isEqualTo(8080); |
|
|
|
|
assertThat(uriComponents.getPath()).isEqualTo("/test/print"); |
|
|
|
|
assertThat(uriComponents.getPathSegments()).isEqualTo(Arrays.asList("test", "print")); |
|
|
|
|
assertThat(uriComponents.getQuery()).isNull(); |
|
|
|
|
assertThat(uriComponents.getFragment()).isNull(); |
|
|
|
|
assertThat(uriComponents.toUri().toString()).isEqualTo(httpUrl); |
|
|
|
|
|
|
|
|
|
httpUrl = "http://user:test@localhost:8080/test/print?foo=bar"; |
|
|
|
|
uriComponents = UriComponentsBuilder.fromHttpUrl(httpUrl).build(); |
|
|
|
|
assertThat(uriComponents.getScheme()).isEqualTo("http"); |
|
|
|
|
assertThat(uriComponents.getUserInfo()).isEqualTo("user:test"); |
|
|
|
|
assertThat(uriComponents.getHost()).isEqualTo("localhost"); |
|
|
|
|
assertThat(uriComponents.getPort()).isEqualTo(8080); |
|
|
|
|
assertThat(uriComponents.getPath()).isEqualTo("/test/print"); |
|
|
|
|
assertThat(uriComponents.getPathSegments()).isEqualTo(Arrays.asList("test", "print")); |
|
|
|
|
assertThat(uriComponents.getQuery()).isEqualTo("foo=bar"); |
|
|
|
|
assertThat(uriComponents.getFragment()).isNull(); |
|
|
|
|
assertThat(uriComponents.toUri().toString()).isEqualTo(httpUrl); |
|
|
|
|
|
|
|
|
|
httpUrl = "http://localhost:8080/test/print?foo=bar"; |
|
|
|
|
uriComponents = UriComponentsBuilder.fromHttpUrl(httpUrl).build(); |
|
|
|
|
assertThat(uriComponents.getScheme()).isEqualTo("http"); |
|
|
|
|
assertThat(uriComponents.getUserInfo()).isNull(); |
|
|
|
|
assertThat(uriComponents.getHost()).isEqualTo("localhost"); |
|
|
|
|
assertThat(uriComponents.getPort()).isEqualTo(8080); |
|
|
|
|
assertThat(uriComponents.getPath()).isEqualTo("/test/print"); |
|
|
|
|
assertThat(uriComponents.getPathSegments()).isEqualTo(Arrays.asList("test", "print")); |
|
|
|
|
assertThat(uriComponents.getQuery()).isEqualTo("foo=bar"); |
|
|
|
|
assertThat(uriComponents.getFragment()).isNull(); |
|
|
|
|
assertThat(uriComponents.toUri().toString()).isEqualTo(httpUrl); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // gh-25300
|
|
|
|
|
void fromHttpUrlWithFragment() { |
|
|
|
|
String httpUrl = "https://example.com#baz"; |
|
|
|
|
UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl(httpUrl).build(); |
|
|
|
|
assertThat(uriComponents.getScheme()).isEqualTo("https"); |
|
|
|
|
assertThat(uriComponents.getUserInfo()).isNull(); |
|
|
|
|
assertThat(uriComponents.getHost()).isEqualTo("example.com"); |
|
|
|
|
assertThat(uriComponents.getPort()).isEqualTo(-1); |
|
|
|
|
assertThat(uriComponents.getPath()).isNullOrEmpty(); |
|
|
|
|
assertThat(uriComponents.getPathSegments()).isEmpty(); |
|
|
|
|
assertThat(uriComponents.getQuery()).isNull(); |
|
|
|
|
assertThat(uriComponents.getFragment()).isEqualTo("baz"); |
|
|
|
|
assertThat(uriComponents.toUri().toString()).isEqualTo(httpUrl); |
|
|
|
|
|
|
|
|
|
httpUrl = "http://localhost:8080/test/print#baz"; |
|
|
|
|
uriComponents = UriComponentsBuilder.fromHttpUrl(httpUrl).build(); |
|
|
|
|
assertThat(uriComponents.getScheme()).isEqualTo("http"); |
|
|
|
|
assertThat(uriComponents.getUserInfo()).isNull(); |
|
|
|
|
assertThat(uriComponents.getHost()).isEqualTo("localhost"); |
|
|
|
|
assertThat(uriComponents.getPort()).isEqualTo(8080); |
|
|
|
|
assertThat(uriComponents.getPath()).isEqualTo("/test/print"); |
|
|
|
|
assertThat(uriComponents.getPathSegments()).isEqualTo(Arrays.asList("test", "print")); |
|
|
|
|
assertThat(uriComponents.getQuery()).isNull(); |
|
|
|
|
assertThat(uriComponents.getFragment()).isEqualTo("baz"); |
|
|
|
|
assertThat(uriComponents.toUri().toString()).isEqualTo(httpUrl); |
|
|
|
|
|
|
|
|
|
httpUrl = "http://localhost:8080/test/print?foo=bar#baz"; |
|
|
|
|
uriComponents = UriComponentsBuilder.fromHttpUrl(httpUrl).build(); |
|
|
|
|
assertThat(uriComponents.getScheme()).isEqualTo("http"); |
|
|
|
|
assertThat(uriComponents.getUserInfo()).isNull(); |
|
|
|
|
assertThat(uriComponents.getHost()).isEqualTo("localhost"); |
|
|
|
|
assertThat(uriComponents.getPort()).isEqualTo(8080); |
|
|
|
|
assertThat(uriComponents.getPath()).isEqualTo("/test/print"); |
|
|
|
|
assertThat(uriComponents.getPathSegments()).isEqualTo(Arrays.asList("test", "print")); |
|
|
|
|
assertThat(uriComponents.getQuery()).isEqualTo("foo=bar"); |
|
|
|
|
assertThat(uriComponents.getFragment()).isEqualTo("baz"); |
|
|
|
|
assertThat(uriComponents.toUri().toString()).isEqualTo(httpUrl); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void fromHttpRequest() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.setScheme("http"); |
|
|
|
|
request.setServerName("localhost"); |
|
|
|
|
@ -259,7 +344,7 @@ public class UriComponentsBuilderTests {
@@ -259,7 +344,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-12771
|
|
|
|
|
public void fromHttpRequestResetsPortBeforeSettingIt() { |
|
|
|
|
void fromHttpRequestResetsPortBeforeSettingIt() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.addHeader("X-Forwarded-Proto", "https"); |
|
|
|
|
request.addHeader("X-Forwarded-Host", "84.198.58.199"); |
|
|
|
|
@ -279,7 +364,7 @@ public class UriComponentsBuilderTests {
@@ -279,7 +364,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-14761
|
|
|
|
|
public void fromHttpRequestWithForwardedIPv4Host() { |
|
|
|
|
void fromHttpRequestWithForwardedIPv4Host() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.setScheme("https"); |
|
|
|
|
request.setServerName("localhost"); |
|
|
|
|
@ -294,7 +379,7 @@ public class UriComponentsBuilderTests {
@@ -294,7 +379,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-14761
|
|
|
|
|
public void fromHttpRequestWithForwardedIPv6() { |
|
|
|
|
void fromHttpRequestWithForwardedIPv6() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.setScheme("http"); |
|
|
|
|
request.setServerName("localhost"); |
|
|
|
|
@ -309,7 +394,7 @@ public class UriComponentsBuilderTests {
@@ -309,7 +394,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-14761
|
|
|
|
|
public void fromHttpRequestWithForwardedIPv6Host() { |
|
|
|
|
void fromHttpRequestWithForwardedIPv6Host() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.setScheme("http"); |
|
|
|
|
request.setServerName("localhost"); |
|
|
|
|
@ -324,7 +409,7 @@ public class UriComponentsBuilderTests {
@@ -324,7 +409,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-14761
|
|
|
|
|
public void fromHttpRequestWithForwardedIPv6HostAndPort() { |
|
|
|
|
void fromHttpRequestWithForwardedIPv6HostAndPort() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.setScheme("http"); |
|
|
|
|
request.setServerName("localhost"); |
|
|
|
|
@ -339,7 +424,7 @@ public class UriComponentsBuilderTests {
@@ -339,7 +424,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void fromHttpRequestWithForwardedHost() { |
|
|
|
|
void fromHttpRequestWithForwardedHost() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.setScheme("https"); |
|
|
|
|
request.setServerName("localhost"); |
|
|
|
|
@ -354,7 +439,7 @@ public class UriComponentsBuilderTests {
@@ -354,7 +439,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-10701
|
|
|
|
|
public void fromHttpRequestWithForwardedHostIncludingPort() { |
|
|
|
|
void fromHttpRequestWithForwardedHostIncludingPort() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.setScheme("http"); |
|
|
|
|
request.setServerName("localhost"); |
|
|
|
|
@ -370,7 +455,7 @@ public class UriComponentsBuilderTests {
@@ -370,7 +455,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-11140
|
|
|
|
|
public void fromHttpRequestWithForwardedHostMultiValuedHeader() { |
|
|
|
|
void fromHttpRequestWithForwardedHostMultiValuedHeader() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.setScheme("http"); |
|
|
|
|
request.setServerName("localhost"); |
|
|
|
|
@ -385,7 +470,7 @@ public class UriComponentsBuilderTests {
@@ -385,7 +470,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-11855
|
|
|
|
|
public void fromHttpRequestWithForwardedHostAndPort() { |
|
|
|
|
void fromHttpRequestWithForwardedHostAndPort() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.setScheme("http"); |
|
|
|
|
request.setServerName("localhost"); |
|
|
|
|
@ -401,7 +486,7 @@ public class UriComponentsBuilderTests {
@@ -401,7 +486,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-11872
|
|
|
|
|
public void fromHttpRequestWithForwardedHostWithDefaultPort() { |
|
|
|
|
void fromHttpRequestWithForwardedHostWithDefaultPort() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.setScheme("http"); |
|
|
|
|
request.setServerName("localhost"); |
|
|
|
|
@ -416,7 +501,7 @@ public class UriComponentsBuilderTests {
@@ -416,7 +501,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-16262
|
|
|
|
|
public void fromHttpRequestWithForwardedProtoWithDefaultPort() { |
|
|
|
|
void fromHttpRequestWithForwardedProtoWithDefaultPort() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.setScheme("http"); |
|
|
|
|
request.setServerName("example.org"); |
|
|
|
|
@ -432,7 +517,7 @@ public class UriComponentsBuilderTests {
@@ -432,7 +517,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-16863
|
|
|
|
|
public void fromHttpRequestWithForwardedSsl() { |
|
|
|
|
void fromHttpRequestWithForwardedSsl() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.setScheme("http"); |
|
|
|
|
request.setServerName("example.org"); |
|
|
|
|
@ -448,7 +533,7 @@ public class UriComponentsBuilderTests {
@@ -448,7 +533,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void fromHttpRequestWithForwardedHostWithForwardedScheme() { |
|
|
|
|
void fromHttpRequestWithForwardedHostWithForwardedScheme() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.setScheme("http"); |
|
|
|
|
request.setServerName("localhost"); |
|
|
|
|
@ -465,7 +550,7 @@ public class UriComponentsBuilderTests {
@@ -465,7 +550,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-12771
|
|
|
|
|
public void fromHttpRequestWithForwardedProtoAndDefaultPort() { |
|
|
|
|
void fromHttpRequestWithForwardedProtoAndDefaultPort() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.setScheme("http"); |
|
|
|
|
request.setServerName("localhost"); |
|
|
|
|
@ -482,7 +567,7 @@ public class UriComponentsBuilderTests {
@@ -482,7 +567,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-12813
|
|
|
|
|
public void fromHttpRequestWithForwardedPortMultiValueHeader() { |
|
|
|
|
void fromHttpRequestWithForwardedPortMultiValueHeader() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.setScheme("http"); |
|
|
|
|
request.setServerName("localhost"); |
|
|
|
|
@ -498,7 +583,7 @@ public class UriComponentsBuilderTests {
@@ -498,7 +583,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-12816
|
|
|
|
|
public void fromHttpRequestWithForwardedProtoMultiValueHeader() { |
|
|
|
|
void fromHttpRequestWithForwardedProtoMultiValueHeader() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.setScheme("http"); |
|
|
|
|
request.setServerName("localhost"); |
|
|
|
|
@ -515,14 +600,14 @@ public class UriComponentsBuilderTests {
@@ -515,14 +600,14 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-12742
|
|
|
|
|
public void fromHttpRequestWithTrailingSlash() { |
|
|
|
|
void fromHttpRequestWithTrailingSlash() { |
|
|
|
|
UriComponents before = UriComponentsBuilder.fromPath("/foo/").build(); |
|
|
|
|
UriComponents after = UriComponentsBuilder.newInstance().uriComponents(before).build(); |
|
|
|
|
assertThat(after.getPath()).isEqualTo("/foo/"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // gh-19890
|
|
|
|
|
public void fromHttpRequestWithEmptyScheme() { |
|
|
|
|
void fromHttpRequestWithEmptyScheme() { |
|
|
|
|
HttpRequest request = new HttpRequest() { |
|
|
|
|
@Override |
|
|
|
|
public String getMethodValue() { |
|
|
|
|
@ -545,7 +630,7 @@ public class UriComponentsBuilderTests {
@@ -545,7 +630,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void path() { |
|
|
|
|
void path() { |
|
|
|
|
UriComponentsBuilder builder = UriComponentsBuilder.fromPath("/foo/bar"); |
|
|
|
|
UriComponents result = builder.build(); |
|
|
|
|
|
|
|
|
|
@ -554,7 +639,7 @@ public class UriComponentsBuilderTests {
@@ -554,7 +639,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void pathSegments() { |
|
|
|
|
void pathSegments() { |
|
|
|
|
UriComponentsBuilder builder = UriComponentsBuilder.newInstance(); |
|
|
|
|
UriComponents result = builder.pathSegment("foo").pathSegment("bar").build(); |
|
|
|
|
|
|
|
|
|
@ -563,7 +648,7 @@ public class UriComponentsBuilderTests {
@@ -563,7 +648,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void pathThenPath() { |
|
|
|
|
void pathThenPath() { |
|
|
|
|
UriComponentsBuilder builder = UriComponentsBuilder.fromPath("/foo/bar").path("ba/z"); |
|
|
|
|
UriComponents result = builder.build().encode(); |
|
|
|
|
|
|
|
|
|
@ -572,7 +657,7 @@ public class UriComponentsBuilderTests {
@@ -572,7 +657,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void pathThenPathSegments() { |
|
|
|
|
void pathThenPathSegments() { |
|
|
|
|
UriComponentsBuilder builder = UriComponentsBuilder.fromPath("/foo/bar").pathSegment("ba/z"); |
|
|
|
|
UriComponents result = builder.build().encode(); |
|
|
|
|
|
|
|
|
|
@ -581,7 +666,7 @@ public class UriComponentsBuilderTests {
@@ -581,7 +666,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void pathSegmentsThenPathSegments() { |
|
|
|
|
void pathSegmentsThenPathSegments() { |
|
|
|
|
UriComponentsBuilder builder = UriComponentsBuilder.newInstance().pathSegment("foo").pathSegment("bar"); |
|
|
|
|
UriComponents result = builder.build(); |
|
|
|
|
|
|
|
|
|
@ -590,7 +675,7 @@ public class UriComponentsBuilderTests {
@@ -590,7 +675,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void pathSegmentsThenPath() { |
|
|
|
|
void pathSegmentsThenPath() { |
|
|
|
|
UriComponentsBuilder builder = UriComponentsBuilder.newInstance().pathSegment("foo").path("/"); |
|
|
|
|
UriComponents result = builder.build(); |
|
|
|
|
|
|
|
|
|
@ -599,7 +684,7 @@ public class UriComponentsBuilderTests {
@@ -599,7 +684,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void pathSegmentsSomeEmpty() { |
|
|
|
|
void pathSegmentsSomeEmpty() { |
|
|
|
|
UriComponentsBuilder builder = UriComponentsBuilder.newInstance().pathSegment("", "foo", "", "bar"); |
|
|
|
|
UriComponents result = builder.build(); |
|
|
|
|
|
|
|
|
|
@ -608,13 +693,13 @@ public class UriComponentsBuilderTests {
@@ -608,13 +693,13 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-12398
|
|
|
|
|
public void pathWithDuplicateSlashes() { |
|
|
|
|
void pathWithDuplicateSlashes() { |
|
|
|
|
UriComponents uriComponents = UriComponentsBuilder.fromPath("/foo/////////bar").build(); |
|
|
|
|
assertThat(uriComponents.getPath()).isEqualTo("/foo/bar"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void replacePath() { |
|
|
|
|
void replacePath() { |
|
|
|
|
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString("https://www.ietf.org/rfc/rfc2396.txt"); |
|
|
|
|
builder.replacePath("/rfc/rfc3986.txt"); |
|
|
|
|
UriComponents result = builder.build(); |
|
|
|
|
@ -629,7 +714,7 @@ public class UriComponentsBuilderTests {
@@ -629,7 +714,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void replaceQuery() { |
|
|
|
|
void replaceQuery() { |
|
|
|
|
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString("https://example.com/foo?foo=bar&baz=qux"); |
|
|
|
|
builder.replaceQuery("baz=42"); |
|
|
|
|
UriComponents result = builder.build(); |
|
|
|
|
@ -644,7 +729,7 @@ public class UriComponentsBuilderTests {
@@ -644,7 +729,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void queryParam() { |
|
|
|
|
void queryParam() { |
|
|
|
|
UriComponents result = UriComponentsBuilder.newInstance().queryParam("baz", "qux", 42).build(); |
|
|
|
|
|
|
|
|
|
assertThat(result.getQuery()).isEqualTo("baz=qux&baz=42"); |
|
|
|
|
@ -655,7 +740,7 @@ public class UriComponentsBuilderTests {
@@ -655,7 +740,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void queryParamWithList() { |
|
|
|
|
void queryParamWithList() { |
|
|
|
|
UriComponentsBuilder builder = UriComponentsBuilder.newInstance(); |
|
|
|
|
UriComponents result = builder.queryParam("baz", Arrays.asList("qux", 42)).build(); |
|
|
|
|
|
|
|
|
|
@ -667,7 +752,7 @@ public class UriComponentsBuilderTests {
@@ -667,7 +752,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void emptyQueryParam() { |
|
|
|
|
void emptyQueryParam() { |
|
|
|
|
UriComponentsBuilder builder = UriComponentsBuilder.newInstance(); |
|
|
|
|
UriComponents result = builder.queryParam("baz").build(); |
|
|
|
|
|
|
|
|
|
@ -678,7 +763,7 @@ public class UriComponentsBuilderTests {
@@ -678,7 +763,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void emptyQueryParams() { |
|
|
|
|
void emptyQueryParams() { |
|
|
|
|
UriComponents result = UriComponentsBuilder.newInstance() |
|
|
|
|
.queryParam("baz", Collections.emptyList()) |
|
|
|
|
.queryParam("foo", (Collection<?>) null) |
|
|
|
|
@ -692,7 +777,7 @@ public class UriComponentsBuilderTests {
@@ -692,7 +777,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void replaceQueryParam() { |
|
|
|
|
void replaceQueryParam() { |
|
|
|
|
UriComponentsBuilder builder = UriComponentsBuilder.newInstance().queryParam("baz", "qux", 42); |
|
|
|
|
builder.replaceQueryParam("baz", "xuq", 24); |
|
|
|
|
UriComponents result = builder.build(); |
|
|
|
|
@ -707,7 +792,7 @@ public class UriComponentsBuilderTests {
@@ -707,7 +792,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void replaceQueryParams() { |
|
|
|
|
void replaceQueryParams() { |
|
|
|
|
UriComponentsBuilder builder = UriComponentsBuilder.newInstance().queryParam("baz", Arrays.asList("qux", 42)); |
|
|
|
|
builder.replaceQueryParam("baz", Arrays.asList("xuq", 24)); |
|
|
|
|
UriComponents result = builder.build(); |
|
|
|
|
@ -722,7 +807,7 @@ public class UriComponentsBuilderTests {
@@ -722,7 +807,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void buildAndExpandHierarchical() { |
|
|
|
|
void buildAndExpandHierarchical() { |
|
|
|
|
UriComponents result = UriComponentsBuilder.fromPath("/{foo}").buildAndExpand("fooValue"); |
|
|
|
|
assertThat(result.toUriString()).isEqualTo("/fooValue"); |
|
|
|
|
|
|
|
|
|
@ -734,7 +819,7 @@ public class UriComponentsBuilderTests {
@@ -734,7 +819,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void buildAndExpandOpaque() { |
|
|
|
|
void buildAndExpandOpaque() { |
|
|
|
|
UriComponents result = UriComponentsBuilder.fromUriString("mailto:{user}@{domain}") |
|
|
|
|
.buildAndExpand("foo", "example.com"); |
|
|
|
|
assertThat(result.toUriString()).isEqualTo("mailto:foo@example.com"); |
|
|
|
|
@ -747,21 +832,21 @@ public class UriComponentsBuilderTests {
@@ -747,21 +832,21 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void queryParamWithValueWithEquals() { |
|
|
|
|
void queryParamWithValueWithEquals() { |
|
|
|
|
UriComponents uriComponents = UriComponentsBuilder.fromUriString("https://example.com/foo?bar=baz").build(); |
|
|
|
|
assertThat(uriComponents.toUriString()).isEqualTo("https://example.com/foo?bar=baz"); |
|
|
|
|
assertThat(uriComponents.getQueryParams().get("bar").get(0)).isEqualTo("baz"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void queryParamWithoutValueWithEquals() { |
|
|
|
|
void queryParamWithoutValueWithEquals() { |
|
|
|
|
UriComponents uriComponents = UriComponentsBuilder.fromUriString("https://example.com/foo?bar=").build(); |
|
|
|
|
assertThat(uriComponents.toUriString()).isEqualTo("https://example.com/foo?bar="); |
|
|
|
|
assertThat(uriComponents.getQueryParams().get("bar").get(0)).isEqualTo(""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void queryParamWithoutValueWithoutEquals() { |
|
|
|
|
void queryParamWithoutValueWithoutEquals() { |
|
|
|
|
UriComponents uriComponents = UriComponentsBuilder.fromUriString("https://example.com/foo?bar").build(); |
|
|
|
|
assertThat(uriComponents.toUriString()).isEqualTo("https://example.com/foo?bar"); |
|
|
|
|
|
|
|
|
|
@ -770,7 +855,7 @@ public class UriComponentsBuilderTests {
@@ -770,7 +855,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // gh-24444
|
|
|
|
|
public void opaqueUriDoesNotResetOnNullInput() throws URISyntaxException { |
|
|
|
|
void opaqueUriDoesNotResetOnNullInput() throws URISyntaxException { |
|
|
|
|
URI uri = new URI("urn:ietf:wg:oauth:2.0:oob"); |
|
|
|
|
UriComponents result = UriComponentsBuilder.fromUri(uri) |
|
|
|
|
.host(null) |
|
|
|
|
@ -785,7 +870,7 @@ public class UriComponentsBuilderTests {
@@ -785,7 +870,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void relativeUrls() { |
|
|
|
|
void relativeUrls() { |
|
|
|
|
String baseUrl = "https://example.com"; |
|
|
|
|
assertThat(UriComponentsBuilder.fromUriString(baseUrl + "/foo/../bar").build().toString()) |
|
|
|
|
.isEqualTo(baseUrl + "/foo/../bar"); |
|
|
|
|
@ -808,7 +893,7 @@ public class UriComponentsBuilderTests {
@@ -808,7 +893,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void emptySegments() { |
|
|
|
|
void emptySegments() { |
|
|
|
|
String baseUrl = "https://example.com/abc/"; |
|
|
|
|
assertThat(UriComponentsBuilder.fromUriString(baseUrl).path("/x/y/z").build().toString()) |
|
|
|
|
.isEqualTo("https://example.com/abc/x/y/z"); |
|
|
|
|
@ -821,20 +906,20 @@ public class UriComponentsBuilderTests {
@@ -821,20 +906,20 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void parsesEmptyFragment() { |
|
|
|
|
void parsesEmptyFragment() { |
|
|
|
|
UriComponents components = UriComponentsBuilder.fromUriString("/example#").build(); |
|
|
|
|
assertThat(components.getFragment()).isNull(); |
|
|
|
|
assertThat(components.toString()).isEqualTo("/example"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-13257
|
|
|
|
|
public void parsesEmptyUri() { |
|
|
|
|
void parsesEmptyUri() { |
|
|
|
|
UriComponents components = UriComponentsBuilder.fromUriString("").build(); |
|
|
|
|
assertThat(components.toString()).isEqualTo(""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testCloneAndMerge() { |
|
|
|
|
void testCloneAndMerge() { |
|
|
|
|
UriComponentsBuilder builder1 = UriComponentsBuilder.newInstance(); |
|
|
|
|
builder1.scheme("http").host("e1.com").path("/p1").pathSegment("ps1").queryParam("q1").fragment("f1").encode(); |
|
|
|
|
|
|
|
|
|
@ -857,7 +942,7 @@ public class UriComponentsBuilderTests {
@@ -857,7 +942,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // gh-24772
|
|
|
|
|
public void testDeepClone() { |
|
|
|
|
void testDeepClone() { |
|
|
|
|
HashMap<String, Object> vars = new HashMap<>(); |
|
|
|
|
vars.put("ps1", "foo"); |
|
|
|
|
vars.put("ps2", "bar"); |
|
|
|
|
@ -888,7 +973,7 @@ public class UriComponentsBuilderTests {
@@ -888,7 +973,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-11856
|
|
|
|
|
public void fromHttpRequestForwardedHeader() { |
|
|
|
|
void fromHttpRequestForwardedHeader() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.addHeader("Forwarded", "proto=https; host=84.198.58.199"); |
|
|
|
|
request.setScheme("http"); |
|
|
|
|
@ -904,7 +989,7 @@ public class UriComponentsBuilderTests {
@@ -904,7 +989,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void fromHttpRequestForwardedHeaderQuoted() { |
|
|
|
|
void fromHttpRequestForwardedHeaderQuoted() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.addHeader("Forwarded", "proto=\"https\"; host=\"84.198.58.199\""); |
|
|
|
|
request.setScheme("http"); |
|
|
|
|
@ -920,7 +1005,7 @@ public class UriComponentsBuilderTests {
@@ -920,7 +1005,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void fromHttpRequestMultipleForwardedHeader() { |
|
|
|
|
void fromHttpRequestMultipleForwardedHeader() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.addHeader("Forwarded", "host=84.198.58.199;proto=https"); |
|
|
|
|
request.addHeader("Forwarded", "proto=ftp; host=1.2.3.4"); |
|
|
|
|
@ -937,7 +1022,7 @@ public class UriComponentsBuilderTests {
@@ -937,7 +1022,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void fromHttpRequestMultipleForwardedHeaderComma() { |
|
|
|
|
void fromHttpRequestMultipleForwardedHeaderComma() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.addHeader("Forwarded", "host=84.198.58.199 ;proto=https, proto=ftp; host=1.2.3.4"); |
|
|
|
|
request.setScheme("http"); |
|
|
|
|
@ -953,7 +1038,7 @@ public class UriComponentsBuilderTests {
@@ -953,7 +1038,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void fromHttpRequestForwardedHeaderWithHostPortAndWithoutServerPort() { |
|
|
|
|
void fromHttpRequestForwardedHeaderWithHostPortAndWithoutServerPort() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.addHeader("Forwarded", "proto=https; host=84.198.58.199:9090"); |
|
|
|
|
request.setScheme("http"); |
|
|
|
|
@ -971,7 +1056,7 @@ public class UriComponentsBuilderTests {
@@ -971,7 +1056,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void fromHttpRequestForwardedHeaderWithHostPortAndServerPort() { |
|
|
|
|
void fromHttpRequestForwardedHeaderWithHostPortAndServerPort() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.addHeader("Forwarded", "proto=https; host=84.198.58.199:9090"); |
|
|
|
|
request.setScheme("http"); |
|
|
|
|
@ -990,7 +1075,7 @@ public class UriComponentsBuilderTests {
@@ -990,7 +1075,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void fromHttpRequestForwardedHeaderWithoutHostPortAndWithServerPort() { |
|
|
|
|
void fromHttpRequestForwardedHeaderWithoutHostPortAndWithServerPort() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.addHeader("Forwarded", "proto=https; host=84.198.58.199"); |
|
|
|
|
request.setScheme("http"); |
|
|
|
|
@ -1009,7 +1094,7 @@ public class UriComponentsBuilderTests {
@@ -1009,7 +1094,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-16262
|
|
|
|
|
public void fromHttpRequestForwardedHeaderWithProtoAndServerPort() { |
|
|
|
|
void fromHttpRequestForwardedHeaderWithProtoAndServerPort() { |
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
request.addHeader("Forwarded", "proto=https"); |
|
|
|
|
request.setScheme("http"); |
|
|
|
|
@ -1028,7 +1113,7 @@ public class UriComponentsBuilderTests {
@@ -1028,7 +1113,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-16364
|
|
|
|
|
public void uriComponentsNotEqualAfterNormalization() { |
|
|
|
|
void uriComponentsNotEqualAfterNormalization() { |
|
|
|
|
UriComponents uri1 = UriComponentsBuilder.fromUriString("http://test.com").build().normalize(); |
|
|
|
|
UriComponents uri2 = UriComponentsBuilder.fromUriString("http://test.com/").build(); |
|
|
|
|
|
|
|
|
|
@ -1038,7 +1123,7 @@ public class UriComponentsBuilderTests {
@@ -1038,7 +1123,7 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-17256
|
|
|
|
|
public void uriComponentsWithMergedQueryParams() { |
|
|
|
|
void uriComponentsWithMergedQueryParams() { |
|
|
|
|
String uri = UriComponentsBuilder.fromUriString("http://localhost:8081") |
|
|
|
|
.uriComponents(UriComponentsBuilder.fromUriString("/{path}?sort={sort}").build()) |
|
|
|
|
.queryParam("sort", "another_value").build().toString(); |
|
|
|
|
@ -1047,7 +1132,8 @@ public class UriComponentsBuilderTests {
@@ -1047,7 +1132,8 @@ public class UriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-17630
|
|
|
|
|
public void toUriStringWithCurlyBraces() { |
|
|
|
|
void toUriStringWithCurlyBraces() { |
|
|
|
|
assertThat(UriComponentsBuilder.fromUriString("/path?q={asa}asa").toUriString()).isEqualTo("/path?q=%7Basa%7Dasa"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|