private URI buildUri(HttpRequest request, Joiner joiner) {
URI requestUri = request.getUri();
Map<String, Collection<String>> queryParams = request.getQueryParams();
if (queryParams != null && !queryParams.isEmpty()) {
URIBuilder uriBuilder = new URIBuilder();
for (Map.Entry<String, Collection<String>> stringCollectionEntry : queryParams.entrySet()) {
String key = stringCollectionEntry.getKey();
Collection<String> stringCollection = stringCollectionEntry.getValue();
String value = joiner.join(stringCollection);
uriBuilder.addParameter(key, value);
}
uriBuilder.setFragment(requestUri.getFragment());
uriBuilder.setHost(requestUri.getHost());
uriBuilder.setPath(requestUri.getPath());
uriBuilder.setPort(requestUri.getPort());
uriBuilder.setScheme(requestUri.getScheme());
uriBuilder.setUserInfo(requestUri.getUserInfo());
try {
requestUri = uriBuilder.build();
} catch (URISyntaxException e) {
LOGGER.warn("could not update uri: {}", requestUri);
}
}
return requestUri;