diff --git a/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/builder/FoxHttpRequestBuilder.java b/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/builder/FoxHttpRequestBuilder.java index 1383cb9..6494117 100644 --- a/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/builder/FoxHttpRequestBuilder.java +++ b/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/builder/FoxHttpRequestBuilder.java @@ -334,6 +334,7 @@ public FoxHttpRequestBuilder activateFoxHttpLogger(boolean activate) { */ public FoxHttpRequest build() throws FoxHttpRequestException { FoxHttpRequest request = new FoxHttpRequest(); + request.setFoxHttpClient(this.foxHttpClient); if (this.foxHttpPlaceholderStrategy != null) { request.getFoxHttpPlaceholderStrategy().getPlaceholderMap().putAll(this.foxHttpPlaceholderStrategy.getPlaceholderMap()); @@ -353,7 +354,6 @@ public FoxHttpRequest build() throws FoxHttpRequestException { request.setRequestBody(this.requestBody); request.setFollowRedirect(this.followRedirect); request.setSkipResponseBody(this.skipResponseBody); - request.setFoxHttpClient(this.foxHttpClient); return request; } diff --git a/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/placeholder/DefaultPlaceholderStrategy.java b/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/placeholder/DefaultPlaceholderStrategy.java index 29dafe3..9f94b39 100644 --- a/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/placeholder/DefaultPlaceholderStrategy.java +++ b/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/placeholder/DefaultPlaceholderStrategy.java @@ -6,6 +6,7 @@ import java.util.HashMap; import java.util.Map; +import java.util.regex.Pattern; /** * @author patrick.boesch@viascom.ch @@ -49,11 +50,20 @@ public void addPlaceholder(String placeholder, String value) { } - public String processPlaceholders(String processedURL, FoxHttpClient foxHttpClient) { + public String processPlaceholders(final String processedURL, FoxHttpClient foxHttpClient) { + String parsedString = processedURL; + Pattern p = Pattern.compile(placeholderEscapeCharEnd); for (Map.Entry entry : this.getPlaceholderMap().entrySet()) { - foxHttpClient.getFoxHttpLogger().log("-> " + this.getPlaceholderEscapeCharStart() + entry.getKey() + this.getPlaceholderEscapeCharEnd() + " -> " + entry.getValue()); - processedURL = processedURL.replace(this.getPlaceholderEscapeCharStart() + entry.getKey() + this.getPlaceholderEscapeCharEnd(), entry.getValue()); + if (p.matcher(parsedString).find()) { + parsedString = parsedString.replace(this.getPlaceholderEscapeCharStart() + entry.getKey() + this.getPlaceholderEscapeCharEnd(), entry.getValue()); + foxHttpClient.getFoxHttpLogger().log( + processedURL + + " -> (" + this.getPlaceholderEscapeCharStart() + entry.getKey() + this.getPlaceholderEscapeCharEnd() + " -> " + entry.getValue() + + ") -> " + parsedString); + } else { + break; + } } - return processedURL; + return parsedString; } }