io.undertow.server.HttpUpgradeListener Java Examples
The following examples show how to use
io.undertow.server.HttpUpgradeListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChannelUpgradeHandler.java From lams with GNU General Public License v2.0 | 6 votes |
public void handleRequest(final HttpServerExchange exchange) throws Exception { final List<String> upgradeStrings = exchange.getRequestHeaders().get(Headers.UPGRADE); if (upgradeStrings != null && exchange.getRequestMethod().equals(Methods.GET)) { for (String string : upgradeStrings) { final List<Holder> holders = handlers.get(string); if (holders != null) { for (Holder holder : holders) { final HttpUpgradeListener listener = holder.listener; if (holder.handshake != null) { if (!holder.handshake.handleUpgrade(exchange)) { //handshake did not match, try again continue; } } exchange.upgradeChannel(string,listener); exchange.endExchange(); return; } } } } nonUpgradeHandler.handleRequest(exchange); }
Example #2
Source File: ChannelUpgradeHandler.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Remove a protocol from this handler. * * @param productString the product string to match * @param upgradeListener The upgrade listener */ public synchronized void removeProtocol(String productString, HttpUpgradeListener upgradeListener) { List<Holder> holders = handlers.get(productString); if (holders == null) { return; } Iterator<Holder> it = holders.iterator(); while (it.hasNext()) { Holder holder = it.next(); if (holder.listener == upgradeListener) { holders.remove(holder); break; } } if (holders.isEmpty()) { handlers.remove(productString); } }
Example #3
Source File: WebSocketServlet.java From lams with GNU General Public License v2.0 | 5 votes |
@Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { final ServletWebSocketHttpExchange facade = new ServletWebSocketHttpExchange(req, resp, peerConnections); Handshake handshaker = null; for (Handshake method : handshakes) { if (method.matches(facade)) { handshaker = method; break; } } if (handshaker == null) { UndertowLogger.REQUEST_LOGGER.debug("Could not find hand shaker for web socket request"); resp.sendError(StatusCodes.BAD_REQUEST); return; } final Handshake selected = handshaker; facade.upgradeChannel(new HttpUpgradeListener() { @Override public void handleUpgrade(StreamConnection streamConnection, HttpServerExchange exchange) { WebSocketChannel channel = selected.createChannel(facade, streamConnection, facade.getBufferPool()); peerConnections.add(channel); callback.onConnect(facade, channel); } }); handshaker.handshake(facade); }
Example #4
Source File: UndertowRequestUpgradeStrategy.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override protected void upgradeInternal(ServerHttpRequest request, ServerHttpResponse response, String selectedProtocol, List<Extension> selectedExtensions, final Endpoint endpoint) throws HandshakeFailureException { HttpServletRequest servletRequest = getHttpServletRequest(request); HttpServletResponse servletResponse = getHttpServletResponse(response); final ServletWebSocketHttpExchange exchange = createHttpExchange(servletRequest, servletResponse); exchange.putAttachment(HandshakeUtil.PATH_PARAMS, Collections.<String, String>emptyMap()); ServerWebSocketContainer wsContainer = (ServerWebSocketContainer) getContainer(servletRequest); final EndpointSessionHandler endpointSessionHandler = new EndpointSessionHandler(wsContainer); final ConfiguredServerEndpoint configuredServerEndpoint = createConfiguredServerEndpoint( selectedProtocol, selectedExtensions, endpoint, servletRequest); final Handshake handshake = getHandshakeToUse(exchange, configuredServerEndpoint); exchange.upgradeChannel(new HttpUpgradeListener() { @Override public void handleUpgrade(StreamConnection connection, HttpServerExchange serverExchange) { Object bufferPool = ReflectionUtils.invokeMethod(getBufferPoolMethod, exchange); WebSocketChannel channel = (WebSocketChannel) ReflectionUtils.invokeMethod( createChannelMethod, handshake, exchange, connection, bufferPool); if (peerConnections != null) { peerConnections.add(channel); } endpointSessionHandler.onConnect(exchange, channel); } }); handshake.handshake(exchange); }
Example #5
Source File: WebSocketProtocolHandshakeHandler.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Create a new {@link WebSocketProtocolHandshakeHandler} * * @param callback The {@link WebSocketConnectionCallback} which will be executed once the handshake was * established */ public WebSocketProtocolHandshakeHandler(final HttpUpgradeListener callback, final HttpHandler next) { this.callback = null; Set<Handshake> handshakes = new HashSet<>(); handshakes.add(new Hybi13Handshake()); handshakes.add(new Hybi08Handshake()); handshakes.add(new Hybi07Handshake()); this.handshakes = handshakes; this.next = next; this.upgradeListener = callback; }
Example #6
Source File: InVMConnection.java From thorntail with Apache License 2.0 | 4 votes |
@Override protected void setConnectListener(HttpUpgradeListener connectListener) { //ignore }
Example #7
Source File: ServletInitialHandler.java From lams with GNU General Public License v2.0 | 4 votes |
@Override protected void setUpgradeListener(HttpUpgradeListener upgradeListener) { //ignore }
Example #8
Source File: InVMConnection.java From thorntail with Apache License 2.0 | 4 votes |
@Override protected void setUpgradeListener(HttpUpgradeListener upgradeListener) { //ignore }
Example #9
Source File: InVMConnection.java From thorntail with Apache License 2.0 | 4 votes |
@Override protected void setConnectListener(HttpUpgradeListener connectListener) { //ignore }
Example #10
Source File: InVMConnection.java From thorntail with Apache License 2.0 | 4 votes |
@Override protected void setUpgradeListener(HttpUpgradeListener upgradeListener) { //ignore }
Example #11
Source File: AsyncWebSocketHttpServerExchange.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void upgradeChannel(final HttpUpgradeListener upgradeCallback) { exchange.upgradeChannel(upgradeCallback); }
Example #12
Source File: ChannelUpgradeHandler.java From lams with GNU General Public License v2.0 | 4 votes |
private Holder(final HttpUpgradeListener listener, final HttpUpgradeHandshake handshake, ChannelListener<? super StreamConnection> channelListener) { this.listener = listener; this.handshake = handshake; this.channelListener = channelListener; }
Example #13
Source File: HttpServerConnection.java From lams with GNU General Public License v2.0 | 4 votes |
@Override protected void setConnectListener(HttpUpgradeListener connectListener) { this.upgradeListener = connectListener; connectHandled = true; }
Example #14
Source File: HttpServerConnection.java From lams with GNU General Public License v2.0 | 4 votes |
@Override protected void setUpgradeListener(HttpUpgradeListener upgradeListener) { this.upgradeListener = upgradeListener; }
Example #15
Source File: HttpServerConnection.java From lams with GNU General Public License v2.0 | 4 votes |
protected HttpUpgradeListener getUpgradeListener() { return upgradeListener; }
Example #16
Source File: Http2ServerConnection.java From lams with GNU General Public License v2.0 | 4 votes |
@Override protected void setUpgradeListener(HttpUpgradeListener upgradeListener) { throw UndertowMessages.MESSAGES.upgradeNotSupported(); }
Example #17
Source File: AjpServerConnection.java From lams with GNU General Public License v2.0 | 4 votes |
@Override protected void setConnectListener(HttpUpgradeListener connectListener) { throw UndertowMessages.MESSAGES.connectNotSupported(); }
Example #18
Source File: ServletWebSocketHttpExchange.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void upgradeChannel(final HttpUpgradeListener upgradeCallback) { exchange.upgradeChannel(upgradeCallback); }
Example #19
Source File: ServletInitialHandler.java From lams with GNU General Public License v2.0 | 4 votes |
@Override protected void setConnectListener(HttpUpgradeListener connectListener) { //ignore }
Example #20
Source File: WebSocketProtocolHandshakeHandler.java From lams with GNU General Public License v2.0 | 3 votes |
/** * Create a new {@link WebSocketProtocolHandshakeHandler} * * @param handshakes The supported handshake methods * @param callback The {@link WebSocketConnectionCallback} which will be executed once the handshake was * established */ public WebSocketProtocolHandshakeHandler(Collection<Handshake> handshakes, final HttpUpgradeListener callback, final HttpHandler next) { this.callback = null; this.handshakes = new HashSet<>(handshakes); this.next = next; this.upgradeListener = callback; }
Example #21
Source File: ChannelUpgradeHandler.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Add a protocol to this handler. * * @param productString the product string to match * @param openListener the open listener to call */ public void addProtocol(String productString, HttpUpgradeListener openListener) { addProtocol(productString, openListener, null); }
Example #22
Source File: ChannelUpgradeHandler.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Add a protocol to this handler. * * @param productString the product string to match * @param openListener the open listener to call * @param handshake a handshake implementation that can be used to verify the client request and modify the response */ public synchronized void addProtocol(String productString, HttpUpgradeListener openListener, final HttpUpgradeHandshake handshake) { addProtocol(productString, openListener, null, handshake); }
Example #23
Source File: WebSocketHttpExchange.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Upgrade the underlying channel * * @param upgradeCallback */ void upgradeChannel(final HttpUpgradeListener upgradeCallback);
Example #24
Source File: WebSocketProtocolHandshakeHandler.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Create a new {@link WebSocketProtocolHandshakeHandler} * * @param callback The {@link WebSocketConnectionCallback} which will be executed once the handshake was * established */ public WebSocketProtocolHandshakeHandler(final HttpUpgradeListener callback) { this(callback, ResponseCodeHandler.HANDLE_404); }
Example #25
Source File: WebSocketProtocolHandshakeHandler.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Create a new {@link WebSocketProtocolHandshakeHandler} * * @param handshakes The supported handshake methods * @param callback The {@link WebSocketConnectionCallback} which will be executed once the handshake was * established */ public WebSocketProtocolHandshakeHandler(Collection<Handshake> handshakes, final HttpUpgradeListener callback) { this(handshakes, callback, ResponseCodeHandler.HANDLE_404); }
Example #26
Source File: Http2ServerConnection.java From lams with GNU General Public License v2.0 | 2 votes |
@Override protected void setConnectListener(HttpUpgradeListener connectListener) { }