Skip to content

Commit

Permalink
Exclude URL query from checkpoint in DefaultWebClient
Browse files Browse the repository at this point in the history
Closes gh-29148
  • Loading branch information
rstoyanchev committed Nov 11, 2022
1 parent 09b19d7 commit f9d8367
Showing 1 changed file with 17 additions and 3 deletions.
Expand Up @@ -17,6 +17,7 @@
package org.springframework.web.reactive.function.client;

import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.time.ZonedDateTime;
import java.util.ArrayList;
Expand Down Expand Up @@ -49,6 +50,7 @@
import org.springframework.util.CollectionUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import org.springframework.web.reactive.function.BodyExtractor;
import org.springframework.web.reactive.function.BodyInserter;
import org.springframework.web.reactive.function.BodyInserters;
Expand Down Expand Up @@ -667,10 +669,22 @@ private <T> Mono<T> applyStatusHandlers(ClientResponse response) {
}

private <T> Mono<T> insertCheckpoint(Mono<T> result, int statusCode, HttpRequest request) {
String httpMethod = request.getMethodValue();
String method = request.getMethodValue();
URI uri = getUriToLog(request);
return result.checkpoint(statusCode + " from " + method + " " + uri + " [DefaultWebClient]");
}

private static URI getUriToLog(HttpRequest request) {
URI uri = request.getURI();
String description = statusCode + " from " + httpMethod + " " + uri + " [DefaultWebClient]";
return result.checkpoint(description);
if (StringUtils.hasText(uri.getQuery())) {
try {
uri = new URI(uri.getScheme(), uri.getHost(), uri.getPath(), null);
}
catch (URISyntaxException ex) {
// ignore
}
}
return uri;
}


Expand Down

0 comments on commit f9d8367

Please sign in to comment.