WebSocket / making sure that filter always sees the correct target path, regardless of servlets
This commit is contained in:
parent
09f01963ca
commit
4b3541b7d1
|
@ -45,6 +45,12 @@ public class OnErrorCallable extends JsrCallable
|
|||
|
||||
public void call(Object endpoint, Throwable cause)
|
||||
{
|
||||
if (idxThrowable == (-1))
|
||||
{
|
||||
idxThrowable = findIndexForRole(Param.Role.ERROR_CAUSE);
|
||||
assertRoleRequired(idxThrowable,"Throwable");
|
||||
}
|
||||
|
||||
if (idxThrowable >= 0)
|
||||
{
|
||||
super.args[idxThrowable] = cause;
|
||||
|
|
|
@ -45,7 +45,10 @@ public class EchoClientSocket extends TrackingSocket
|
|||
|
||||
public void close() throws IOException
|
||||
{
|
||||
this.session.close(new CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE,"Test Complete"));
|
||||
if (session != null)
|
||||
{
|
||||
this.session.close(new CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE,"Test Complete"));
|
||||
}
|
||||
}
|
||||
|
||||
@OnClose
|
||||
|
@ -82,7 +85,7 @@ public class EchoClientSocket extends TrackingSocket
|
|||
addEvent(text);
|
||||
eventCountLatch.countDown();
|
||||
}
|
||||
|
||||
|
||||
public boolean awaitAllEvents(long timeout, TimeUnit unit) throws InterruptedException
|
||||
{
|
||||
return eventCountLatch.await(timeout,unit);
|
||||
|
|
|
@ -110,7 +110,14 @@ public class WebSocketUpgradeFilter extends ContainerLifeCycle implements Filter
|
|||
{
|
||||
HttpServletRequest httpreq = (HttpServletRequest)request;
|
||||
HttpServletResponse httpresp = (HttpServletResponse)response;
|
||||
|
||||
// Since this is a filter, we need to be smart about determining the target path
|
||||
String contextPath = httpreq.getContextPath();
|
||||
String target = httpreq.getRequestURI();
|
||||
if (target.startsWith(contextPath))
|
||||
{
|
||||
target = target.substring(contextPath.length());
|
||||
}
|
||||
|
||||
if (factory.isUpgradeRequest(httpreq,httpresp))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue