@Override public UriBuilder uriBuilder() { return UriComponentsBuilder.fromUri(this.uri); }
@Test // SPR-9317 public void fromUriEncodedQuery() throws URISyntaxException { URI uri = new URI("http://www.example.org/?param=aGVsbG9Xb3JsZA%3D%3D"); String fromUri = UriComponentsBuilder.fromUri(uri).build().getQueryParams().get("param").get(0); String fromUriString = UriComponentsBuilder.fromUriString(uri.toString()) .build().getQueryParams().get("param").get(0); assertEquals(fromUri, fromUriString); }
@Override public UriBuilder uriBuilder() { return UriComponentsBuilder.fromUri(uri()); }
@Override public UriBuilder uriBuilder() { return UriComponentsBuilder.fromUri(this.uri); }
private static MultiValueMap<String, String> getQueryParams(ClientHttpRequest request) { return UriComponentsBuilder.fromUri(request.getURI()).build().getQueryParams(); }
public URI getInfoUrl() { return UriComponentsBuilder.fromUri(this.sockJsUrl) .scheme(getScheme(TransportType.XHR)) .pathSegment("info") .build(true).toUri(); }
public static URI toUri(final URI baseUrl, final String... pathSegments) { return UriComponentsBuilder.fromUri(baseUrl).pathSegment(pathSegments).build().toUri(); } }
public static String addFragmentComponent(String urlString, String component) { URI uri = URI.create(urlString); UriComponentsBuilder builder = UriComponentsBuilder.fromUri(uri); builder.fragment(hasText(uri.getFragment()) ? uri.getFragment() + "&" + component : component); return builder.build().toUriString(); }
private URI getUrlToUse() { MultiValueMap<String, String> params = this.queryParamsBuilder.buildAndExpand().encode().getQueryParams(); if (!params.isEmpty()) { return UriComponentsBuilder.fromUri(this.url).queryParams(params).build(true).toUri(); } return this.url; } }
/** * Create a new {@code UriComponents} object from the URI associated with * the given HttpRequest while also overlaying with values from the headers * "Forwarded" (<a href="http://tools.ietf.org/html/rfc7239">RFC 7239</a>), * or "X-Forwarded-Host", "X-Forwarded-Port", and "X-Forwarded-Proto" if * "Forwarded" is not found. * @param request the source request * @return the URI components of the URI * @since 4.1.5 */ public static UriComponentsBuilder fromHttpRequest(HttpRequest request) { return fromUri(request.getURI()).adaptFromForwardedHeaders(request.getHeaders()); }
public B uri(URI uri) { this.uri = uri; String scheme = this.uri.getScheme(); Assert.hasText(scheme, "The parameter [" + this.uri + "] format is incorrect, scheme can not be empty"); if (this.uri.getPort() < 0 && scheme.startsWith("http")) { // default known http ports int port = this.uri.getScheme().equals("https") ? 443 : 80; this.uri = UriComponentsBuilder.fromUri(this.uri) .port(port) .build(false) .toUri(); } return getThis(); }
public URI getTransportUrl(TransportType transportType) { return UriComponentsBuilder.fromUri(this.sockJsUrl) .scheme(getScheme(transportType)) .pathSegment(getServerId()) .pathSegment(getSessionId()) .pathSegment(transportType.toString()) .build(true).toUri(); }
/** * Create a new {@code UriComponents} object from the URI associated with * the given HttpRequest while also overlaying with values from the headers * "Forwarded" (<a href="http://tools.ietf.org/html/rfc7239">RFC 7239</a>), * or "X-Forwarded-Host", "X-Forwarded-Port", and "X-Forwarded-Proto" if * "Forwarded" is not found. * @param request the source request * @return the URI components of the URI * @since 4.1.5 */ public static UriComponentsBuilder fromHttpRequest(HttpRequest request) { return fromUri(request.getURI()).adaptFromForwardedHeaders(request.getHeaders()); }
private URI getUrlToUse() { MultiValueMap<String, String> params = this.queryParamsBuilder.buildAndExpand().encode().getQueryParams(); if (!params.isEmpty()) { return UriComponentsBuilder.fromUri(this.url).queryParams(params).build(true).toUri(); } return this.url; } }
return UriComponentsBuilder.fromUri(uri).replacePath(null).replaceQuery(null);
public ProjectGenerationStatPublisher(ProjectRequestDocumentFactory documentFactory, StatsProperties statsProperties, RestTemplateBuilder restTemplateBuilder, RetryTemplate retryTemplate) { this.documentFactory = documentFactory; this.objectMapper = createObjectMapper(); StatsProperties.Elastic elastic = statsProperties.getElastic(); UriComponentsBuilder uriBuilder = UriComponentsBuilder .fromUri(determineEntityUrl(elastic)); this.restTemplate = configureAuthorization(restTemplateBuilder, elastic, uriBuilder).build(); this.requestUrl = uriBuilder.userInfo(null).build().toUri(); this.retryTemplate = retryTemplate; }
private static OAuth2AuthorizationResponse convertResponse(ServerWebExchange exchange) { MultiValueMap<String, String> queryParams = exchange.getRequest() .getQueryParams(); String redirectUri = UriComponentsBuilder.fromUri(exchange.getRequest().getURI()) .query(null) .build() .toUriString(); return OAuth2AuthorizationResponseUtils .convert(queryParams, redirectUri); } }
@Test public void fromOpaqueUri() throws URISyntaxException { URI uri = new URI("mailto:foo@bar.com#baz"); UriComponents result = UriComponentsBuilder.fromUri(uri).build(); assertEquals("mailto", result.getScheme()); assertEquals("foo@bar.com", result.getSchemeSpecificPart()); assertEquals("baz", result.getFragment()); assertEquals("Invalid result URI", uri, result.toUri()); }
request.setQueryString(this.url.getRawQuery()); addRequestParams(request, UriComponentsBuilder.fromUri(this.url).build().getQueryParams());
@Test public void fromHierarchicalUri() throws URISyntaxException { URI uri = new URI("http://example.com/foo?bar#baz"); UriComponents result = UriComponentsBuilder.fromUri(uri).build(); assertEquals("http", result.getScheme()); assertEquals("example.com", result.getHost()); assertEquals("/foo", result.getPath()); assertEquals("bar", result.getQuery()); assertEquals("baz", result.getFragment()); assertEquals("Invalid result URI", uri, result.toUri()); }