@Override public DefaultUriBuilder query(String query) { this.uriComponentsBuilder.query(query); return this; }
@Override public DefaultUriBuilder query(String query) { this.uriComponentsBuilder.query(query); return this; }
@Nullable protected final String getCallbackParam(ServerHttpRequest request) { String query = request.getURI().getQuery(); MultiValueMap<String, String> params = UriComponentsBuilder.newInstance().query(query).build().getQueryParams(); String value = params.getFirst("c"); if (StringUtils.isEmpty(value)) { return null; } String result = UriUtils.decode(value, StandardCharsets.UTF_8); return (CALLBACK_PARAM_PATTERN.matcher(result).matches() ? result : null); }
/** * Set the query of this builder overriding all existing query parameters. * @param query the query string; a {@code null} value removes all query parameters. * @return this UriComponentsBuilder */ @Override public UriComponentsBuilder replaceQuery(@Nullable String query) { this.queryParams.clear(); if (query != null) { query(query); } resetSchemeSpecificPart(); return this; }
private MultiValueMap<String, String> getOriginatingRequestParams(HttpServletRequest request) { String query = getUrlPathHelper().getOriginatingQueryString(request); return ServletUriComponentsBuilder.fromPath("/").query(query).build().getQueryParams(); }
private static URI rewriteUrl(UriComponents oldUrl, String targetUrl) { String[] newPathSegments = oldUrl.getPathSegments() .subList(1, oldUrl.getPathSegments().size()) .toArray(new String[]{}); return UriComponentsBuilder.fromUriString(targetUrl) .pathSegment(newPathSegments) .query(oldUrl.getQuery()) .build(true) .toUri(); }
builder.query(matcher.group(10)); return builder;
/** * Set the query of this builder overriding all existing query parameters. * @param query the query string; a {@code null} value removes all query parameters. * @return this UriComponentsBuilder */ @Override public UriComponentsBuilder replaceQuery(@Nullable String query) { this.queryParams.clear(); if (query != null) { query(query); } resetSchemeSpecificPart(); return this; }
query(uri.getRawQuery());
builder.query(query);
@Test public void serializable() throws Exception { UriComponents uriComponents = UriComponentsBuilder.fromUriString( "http://example.com").path("/{foo}").query("bar={baz}").build(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(uriComponents); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray())); UriComponents readObject = (UriComponents) ois.readObject(); assertThat(uriComponents.toString(), equalTo(readObject.toString())); }
builder.query(matcher.group(10)); return builder;
@Test public void equalsHierarchicalUriComponents() { String url = "http://example.com"; UriComponents uric1 = UriComponentsBuilder.fromUriString(url).path("/{foo}").query("bar={baz}").build(); UriComponents uric2 = UriComponentsBuilder.fromUriString(url).path("/{foo}").query("bar={baz}").build(); UriComponents uric3 = UriComponentsBuilder.fromUriString(url).path("/{foo}").query("bin={baz}").build(); assertThat(uric1, instanceOf(HierarchicalUriComponents.class)); assertThat(uric1, equalTo(uric1)); assertThat(uric1, equalTo(uric2)); assertThat(uric1, not(equalTo(uric3))); }
builder.query(query);
private MultiValueMap<String, String> getOriginatingRequestParams(HttpServletRequest request) { String query = getUrlPathHelper().getOriginatingQueryString(request); return ServletUriComponentsBuilder.fromPath("/").query(query).build().getQueryParams(); }
query(uri.getRawQuery());
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); } }
private String getUnsuccessfulRedirect(AuthorizationRequest authorizationRequest, OAuth2Exception failure, boolean fragment) { if (authorizationRequest == null || authorizationRequest.getRedirectUri() == null) { // we have no redirect for the user. very sad. throw new UnapprovedClientAuthenticationException("Authorization failure, and no redirect URI.", failure); } UriComponentsBuilder template = UriComponentsBuilder.fromUriString(authorizationRequest.getRedirectUri()); StringBuilder values = new StringBuilder(); values.append("error=" + encode(failure.getOAuth2ErrorCode())); values.append("&error_description=" + encode(failure.getMessage())); if (authorizationRequest.getState() != null) { values.append("&state=" + encode(authorizationRequest.getState())); } if (failure.getAdditionalInformation() != null) { for (Map.Entry<String, String> additionalInfo : failure.getAdditionalInformation().entrySet()) { values.append("&" + encode(additionalInfo.getKey()) + "=" + encode(additionalInfo.getValue())); } } if (fragment) { template.fragment(values.toString()); } else { template.query(values.toString()); } return template.build(true).toUriString(); }
@RequestMapping(path = REQUEST_MAPPING_PATH, method = {RequestMethod.GET, RequestMethod.HEAD, RequestMethod.POST, RequestMethod.PUT, RequestMethod.PATCH, RequestMethod.DELETE, RequestMethod.OPTIONS}) public Mono<Void> endpointProxy(@PathVariable("instanceId") String instanceId, ServerHttpRequest request, ServerHttpResponse response) { String endpointLocalPath = getEndpointLocalPath(request.getPath().pathWithinApplication().value()); URI uri = UriComponentsBuilder.fromPath(endpointLocalPath) .query(request.getURI().getRawQuery()) .build(true) .toUri(); return super.forward(instanceId, uri, request.getMethod(), request.getHeaders(), () -> BodyInserters.fromDataBuffers(request.getBody())).flatMap(clientResponse -> { response.setStatusCode(clientResponse.statusCode()); response.getHeaders().addAll(filterHeaders(clientResponse.headers().asHttpHeaders())); return response.writeAndFlushWith(clientResponse.body(BodyExtractors.toDataBuffers()).window(1)); }); } }
.query(request.getURI().getRawQuery()) .build(true) .toUri();