Skip to content

Commit d3d6628

Browse files
committed
Fix logged URLs when request fails
1 parent a5eb676 commit d3d6628

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/main/java/eu/openanalytics/containerproxy/util/ProxyMappingManager.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import jakarta.servlet.ServletException;
4949
import jakarta.servlet.http.HttpServletRequest;
5050
import jakarta.servlet.http.HttpServletResponse;
51+
import org.apache.commons.lang3.StringUtils;
5152
import org.slf4j.Logger;
5253
import org.slf4j.LoggerFactory;
5354
import org.springframework.context.annotation.Lazy;
@@ -109,7 +110,10 @@ public class ProxyMappingManager {
109110
try {
110111
proxy = proxyService.getProxy(proxyIdAttachment.proxyId);
111112
if (proxy != null && !proxy.getStatus().isUnavailable() && !isShuttingDown) {
112-
String originalURL = responseExchange.getAttachment(ATTACHMENT_ORIGINAL_URL).url;
113+
String originalURL = responseExchange.getRequestURL();
114+
if (!StringUtils.isBlank(responseExchange.getQueryString())) {
115+
originalURL += "?" + responseExchange.getQueryString();
116+
}
113117
String proxiedTo = getProxiedToFromResponseExchange(proxy, responseExchange);
114118
slogger.info(proxy, String.format("Proxy unreachable/crashed, stopping it now, failed request: %s %s was proxied to: %s, status: %s",
115119
responseExchange.getRequestMethod(), originalURL, proxiedTo, responseExchange.getStatusCode()));
@@ -273,7 +277,10 @@ private String getProxiedToFromResponseExchange(Proxy proxy, HttpServerExchange
273277
String relativePath = responseExchange.getRelativePath();
274278
URI target = getTargetFromResponseExchange(proxy, relativePath);
275279

276-
return target + relativePath + responseExchange.getQueryString();
280+
if (!StringUtils.isBlank(responseExchange.getQueryString())) {
281+
return target + relativePath + "?" + responseExchange.getQueryString();
282+
}
283+
return target + relativePath;
277284
}
278285

279286
private URI getTargetFromResponseExchange(Proxy proxy, String relativePath) {

0 commit comments

Comments
 (0)