if (wsFactory.isUpgradeRequest(req, resp)) { if (wsFactory.acceptWebSocket(req, resp) || resp.isCommitted()) { return; if (wsFactory.isUpgradeRequest(req, resp)) { proxyWebSocket(req, resp, path); } else {
/** * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) */ @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (factory.isUpgradeRequest(request,response)) { // We have an upgrade request if (factory.acceptWebSocket(request,response)) { // We have a socket instance created return; } // If we reach this point, it means we had an incoming request to upgrade // but it was either not a proper websocket upgrade, or it was possibly rejected // due to incoming request constraints (controlled by WebSocketCreator) if (response.isCommitted()) { // not much we can do at this point. return; } } // All other processing super.service(request,response); } }
/** * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) */ @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (factory.isUpgradeRequest(request,response)) { // We have an upgrade request if (factory.acceptWebSocket(request,response)) { // We have a socket instance created return; } // If we reach this point, it means we had an incoming request to upgrade // but it was either not a proper websocket upgrade, or it was possibly rejected // due to incoming request constraints (controlled by WebSocketCreator) if (response.isCommitted()) { // not much we can do at this point. return; } } // All other processing super.service(request,response); } }
/** * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) */ @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (factory.isUpgradeRequest(request,response)) { // We have an upgrade request if (factory.acceptWebSocket(request,response)) { // We have a socket instance created return; } // If we reach this point, it means we had an incoming request to upgrade // but it was either not a proper websocket upgrade, or it was possibly rejected // due to incoming request constraints (controlled by WebSocketCreator) if (response.isCommitted()) { // not much we can do at this point. return; } } // All other processing super.service(request,response); } }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (webSocketFactory.isUpgradeRequest(request, response) && webSocketFactory.acceptWebSocket(request, response)) { baseRequest.setHandled(true); return; } super.handle(target, baseRequest, request, response); }
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HTTPMethod method = HTTPMethod.valueOf(request.getMethod().toUpperCase()); boolean upgradeRequest = webSocketServletFactory.isUpgradeRequest(request, response); if ( upgradeRequest ) { method = HTTPMethod.WEBSOCKET; } GenericMatchedRoute<GenericRequestHandler> route = routeMatcher.match(method, request.getRequestURI()); if ( null == route ) { throw new IllegalStateException("route matcher not configured with a default route!"); } request.setAttribute(MATCHED_ROUTE, route); if ( upgradeRequest ) { request.setAttribute(GenericRequestHandler.class.getName(), route.getValue()); webSocketServletFactory.acceptWebSocket(request, response); } else { route.getValue().service(request, response); } }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (webSocketFactory.isUpgradeRequest(request, response) && webSocketFactory.acceptWebSocket(request, response)) { baseRequest.setHandled(true); return; } super.handle(target, baseRequest, request, response); }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (webSocketFactory.isUpgradeRequest(request,response)) { // We have an upgrade request if (webSocketFactory.acceptWebSocket(request,response)) { // We have a socket instance created baseRequest.setHandled(true); return; } // If we reach this point, it means we had an incoming request to upgrade // but it was either not a proper websocket upgrade, or it was possibly rejected // due to incoming request constraints (controlled by WebSocketCreator) if (response.isCommitted()) { // not much we can do at this point. return; } } super.handle(target,baseRequest,request,response); } }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (webSocketFactory.isUpgradeRequest(request,response)) { // We have an upgrade request if (webSocketFactory.acceptWebSocket(request,response)) { // We have a socket instance created baseRequest.setHandled(true); return; } // If we reach this point, it means we had an incoming request to upgrade // but it was either not a proper websocket upgrade, or it was possibly rejected // due to incoming request constraints (controlled by WebSocketCreator) if (response.isCommitted()) { // not much we can do at this point. return; } } super.handle(target,baseRequest,request,response); } }
public void invoke(final ServletConfig config, final ServletContext context, final HttpServletRequest request, final HttpServletResponse response) throws IOException { WebSocketServletFactory wsf = getWebSocketFactory(config, context); if (wsf.isUpgradeRequest(request, response) && wsf.acceptWebSocket(request, response)) { ((Request)request).setHandled(true); return; } super.invoke(config, context, request, response); }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (webSocketFactory.isUpgradeRequest(request,response)) { // We have an upgrade request if (webSocketFactory.acceptWebSocket(request,response)) { // We have a socket instance created baseRequest.setHandled(true); return; } // If we reach this point, it means we had an incoming request to upgrade // but it was either not a proper websocket upgrade, or it was possibly rejected // due to incoming request constraints (controlled by WebSocketCreator) if (response.isCommitted()) { // not much we can do at this point. return; } } super.handle(target,baseRequest,request,response); } }
public void invoke(final ServletConfig config, final ServletContext context, final HttpServletRequest request, final HttpServletResponse response) throws IOException { WebSocketServletFactory wsf = getWebSocketFactory(config, context); if (wsf.isUpgradeRequest(request, response) && wsf.acceptWebSocket(request, response)) { ((Request)request).setHandled(true); return; } super.invoke(config, context, request, response); }
public boolean serviceError(Integer code, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String path = ( null == code ) ? "/500" : "/"+code; boolean upgradeRequest = webSocketServletFactory.isUpgradeRequest(request, response); HTTPMethod method = upgradeRequest ? HTTPMethod.WEBSOCKET : HTTPMethod.GET; GenericMatchedRoute<GenericRequestHandler> route = routeMatcher.match(method, path); if ( null == route || route.isDefaultRoute() ) { return false; } if ( upgradeRequest ) { request.setAttribute(GenericRequestHandler.class.getName(), route.getValue()); webSocketServletFactory.acceptWebSocket(request, response); } else { route.getValue().service(request, response); } return true; }
HttpServletResponse httpresp = (HttpServletResponse) response; if (!factory.isUpgradeRequest(httpreq, httpresp))
@Override protected void service( final HttpServletRequest req, final HttpServletResponse res ) throws ServletException, IOException { final boolean isWebSocket = this.webSocketServletFactory.isUpgradeRequest( req, res ); final RequestFactory requestFactory = new RequestFactory(); requestFactory.setRequest( req ); requestFactory.setWebSocket( isWebSocket ); final Request actualRequest = requestFactory.create(); final Response actualResponse = serve( actualRequest ); if ( actualResponse == null ) { return; } if ( !isWebSocket ) { new ResponseSerializer( res ).serialize( actualResponse ); return; } final WebSocketConfig config = actualResponse.getWebSocket(); acceptWebSocket( req, res, config ); }