Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions api/src/org/labkey/api/websocket/BrowserEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ public void modifyHandshake(ServerEndpointConfig config, HandshakeRequest reques
@Override
public void onOpen(Session session, EndpointConfig endpointConfig)
{
String uri = null;
try
{
String uri = getWSRemoteUri(session, endpointConfig);
LOG.debug("BrowserEndpoint.onOpen( " + session.getRequestURI() + " -> " + uri);
uri = getWSRemoteUri(session, endpointConfig);
LOG.debug("BrowserEndpoint.onOpen( {} -> {}", session.getRequestURI(), uri);
Map<String, List<String>> requestHeaders = (Map<String, List<String>>) endpointConfig.getUserProperties().get("requestHeaders");
this.browserSession = session;
this.serverEndpoint = new ServerEndpoint(new URI(uri), requestHeaders, endpointConfig.getUserProperties());
Expand All @@ -103,7 +104,7 @@ public void onOpen(Session session, EndpointConfig endpointConfig)
}
catch (URISyntaxException | IOException | DeploymentException | ServletException ex)
{
LOG.debug("BrowserEndpoint.onOpen", ex);
LOG.debug("BrowserEndpoint.onOpen failed to proxy {} -> {}", session.getRequestURI(), uri, ex);
UnexpectedException.rethrow(ex);
}
}
Expand Down Expand Up @@ -138,15 +139,40 @@ class ServerEndpoint extends Endpoint
{
final Map<String,List<String>> proxyHeaders = prepareProxyHeaders(remoteURI, requestHeaders, properties);

// Log what the subclass's prepareProxyHeaders returned
LOG.trace("=== WebSocket proxy: proxyHeaders from prepareProxyHeaders ===");
for (Map.Entry<String, List<String>> entry : proxyHeaders.entrySet())
{
LOG.trace(" proxyHeaders: {} = {}", entry.getKey(), entry.getValue());
}

WebSocketContainer clientEndPoint = ContainerProvider.getWebSocketContainer();
ClientEndpointConfig config = ClientEndpointConfig.Builder.create()
.configurator(new ClientEndpointConfig.Configurator()
{
@Override
public void beforeRequest(Map<String, List<String>> headers)
{
// Log incoming browser headers for debugging
LOG.trace("=== WebSocket proxy: browser request headers ===");
for (Map.Entry<String, List<String>> entry : requestHeaders.entrySet())
{
LOG.trace(" Browser header: {} = {}", entry.getKey(), entry.getValue());
}

headers.putAll(proxyHeaders);
}

@Override
public void afterResponse(HandshakeResponse hr)
{
// Log response headers from backend server for debugging
LOG.trace("=== WebSocket proxy: response headers from backend ===");
for (Map.Entry<String, List<String>> entry : hr.getHeaders().entrySet())
{
LOG.trace(" Response header: {} = {}", entry.getKey(), entry.getValue());
}
}
})
.build();
serverSession = clientEndPoint.connectToServer(this, config, remoteURI);
Expand Down