@Bean public RequestUpgradeStrategy requestUpgradeStrategy() { return new TomcatRequestUpgradeStrategy(); } }
@Override public void upgradeInternal(ServerHttpRequest request, ServerHttpResponse response, @Nullable String selectedProtocol, List<Extension> selectedExtensions, Endpoint endpoint) throws HandshakeFailureException { HttpServletRequest servletRequest = getHttpServletRequest(request); HttpServletResponse servletResponse = getHttpServletResponse(response); StringBuffer requestUrl = servletRequest.getRequestURL(); String path = servletRequest.getRequestURI(); // shouldn't matter Map<String, String> pathParams = Collections.<String, String> emptyMap(); ServerEndpointRegistration endpointConfig = new ServerEndpointRegistration(path, endpoint); endpointConfig.setSubprotocols(Collections.singletonList(selectedProtocol)); endpointConfig.setExtensions(selectedExtensions); try { getContainer(servletRequest).doUpgrade(servletRequest, servletResponse, endpointConfig, pathParams); } catch (ServletException ex) { throw new HandshakeFailureException( "Servlet request failed to upgrade to WebSocket: " + requestUrl, ex); } catch (IOException ex) { throw new HandshakeFailureException( "Response update failed during upgrade to WebSocket: " + requestUrl, ex); } }
@Override public void upgradeInternal(ServerHttpRequest request, ServerHttpResponse response, @Nullable String selectedProtocol, List<Extension> selectedExtensions, Endpoint endpoint) throws HandshakeFailureException { HttpServletRequest servletRequest = getHttpServletRequest(request); HttpServletResponse servletResponse = getHttpServletResponse(response); StringBuffer requestUrl = servletRequest.getRequestURL(); String path = servletRequest.getRequestURI(); // shouldn't matter Map<String, String> pathParams = Collections.<String, String> emptyMap(); ServerEndpointRegistration endpointConfig = new ServerEndpointRegistration(path, endpoint); endpointConfig.setSubprotocols(Collections.singletonList(selectedProtocol)); endpointConfig.setExtensions(selectedExtensions); try { getContainer(servletRequest).doUpgrade(servletRequest, servletResponse, endpointConfig, pathParams); } catch (ServletException ex) { throw new HandshakeFailureException( "Servlet request failed to upgrade to WebSocket: " + requestUrl, ex); } catch (IOException ex) { throw new HandshakeFailureException( "Response update failed during upgrade to WebSocket: " + requestUrl, ex); } }
@Override protected void registerStompEndpoints(StompEndpointRegistry registry) { // Can't rely on classpath detection RequestUpgradeStrategy upgradeStrategy = new TomcatRequestUpgradeStrategy(); registry.addEndpoint("/stomp") .setHandshakeHandler(new DefaultHandshakeHandler(upgradeStrategy)) .setAllowedOrigins("*"); }
@Override public void upgradeInternal(ServerHttpRequest request, ServerHttpResponse response, @Nullable String selectedProtocol, List<Extension> selectedExtensions, Endpoint endpoint) throws HandshakeFailureException { HttpServletRequest servletRequest = getHttpServletRequest(request); HttpServletResponse servletResponse = getHttpServletResponse(response); StringBuffer requestUrl = servletRequest.getRequestURL(); String path = servletRequest.getRequestURI(); // shouldn't matter Map<String, String> pathParams = Collections.<String, String> emptyMap(); ServerEndpointRegistration endpointConfig = new ServerEndpointRegistration(path, endpoint); endpointConfig.setSubprotocols(Collections.singletonList(selectedProtocol)); endpointConfig.setExtensions(selectedExtensions); try { getContainer(servletRequest).doUpgrade(servletRequest, servletResponse, endpointConfig, pathParams); } catch (ServletException ex) { throw new HandshakeFailureException( "Servlet request failed to upgrade to WebSocket: " + requestUrl, ex); } catch (IOException ex) { throw new HandshakeFailureException( "Response update failed during upgrade to WebSocket: " + requestUrl, ex); } }
@Bean public DefaultHandshakeHandler handshakeHandler() { return new DefaultHandshakeHandler(new TomcatRequestUpgradeStrategy()); }
@Bean public DefaultHandshakeHandler handshakeHandler() { return new DefaultHandshakeHandler(new TomcatRequestUpgradeStrategy()); }
@Bean public DefaultHandshakeHandler handshakeHandler() { return new DefaultHandshakeHandler(new TomcatRequestUpgradeStrategy()); }