Package io.undertow.protocols.http2

Examples of io.undertow.protocols.http2.Http2RstStreamSinkChannel


        String existing = (String) sslEngine.getSession().getValue(PROTOCOL_KEY);
        //resuming an existing session, no need for ALPN
        if (existing != null) {
            UndertowLogger.REQUEST_LOGGER.debug("Resuming existing session, not doing NPN negotiation");
            if (existing.equals(HTTP2)) {
                Http2Channel sc = new Http2Channel(channel, bufferPool, new ImmediatePooled<>(ByteBuffer.wrap(new byte[0])), false, false, undertowOptions);
                sc.getReceiveSetter().set(new Http2ReceiveListener(rootHandler, getUndertowOptions(), bufferSize, statisticsEnabled ? connectorStatistics : null));
                sc.resumeReceives();
            } else {
                if (delegate == null) {
                    UndertowLogger.REQUEST_IO_LOGGER.couldNotInitiateHttp2Connection();
                    IoUtils.safeClose(channel);
                    return;
View Full Code Here


                    }
                    buffer.getResource().flip();
                    if (HTTP2.equals(selected)) {

                        //cool, we have a Http2 connection.
                        Http2Channel channel = new Http2Channel(this.channel, bufferPool, buffer, false, false, undertowOptions);
                        Integer idleTimeout = undertowOptions.get(UndertowOptions.IDLE_TIMEOUT);
                        if (idleTimeout != null && idleTimeout > 0) {
                            channel.setIdleTimeout(idleTimeout);
                        }
                        if(statisticsEnabled) {
                            this.channel.getSinkChannel().setConduit(new BytesSentStreamSinkConduit(this.channel.getSinkChannel().getConduit(), connectorStatistics.sentAccumulator()));
                            this.channel.getSourceChannel().setConduit(new BytesReceivedStreamSourceConduit(this.channel.getSourceChannel().getConduit(), connectorStatistics.sentAccumulator()));
                        }
                        free = false;
                        channel.getReceiveSetter().set(new Http2ReceiveListener(rootHandler, getUndertowOptions(), bufferSize, connectorStatistics));
                        channel.resumeReceives();
                        return;
                    } else if (HTTP_1_1.equals(selected) || res > 0) {
                        if (delegate == null) {
                            UndertowLogger.REQUEST_IO_LOGGER.couldNotInitiateHttp2Connection();
                            IoUtils.safeClose(channel);
                            return;
                        }
                        channel.getSourceChannel().setReadListener(null);
                        if (res > 0) {
                            PushBackStreamSourceConduit pushBackStreamSourceConduit = new PushBackStreamSourceConduit(channel.getSourceChannel().getConduit());
                            channel.getSourceChannel().setConduit(pushBackStreamSourceConduit);
                            pushBackStreamSourceConduit.pushBack(buffer);
                            free = false;
                        }
                        delegate.handleEvent(channel);
                        return;
                    } else if (res == 0) {
                        channel.getSourceChannel().resumeReads();
                        return;
                    }
                }

            } catch (IOException e) {
View Full Code Here

                final ByteBuffer settingsFrame = FlexBase64.decode(settings);
                exchange.upgradeChannel(new HttpUpgradeListener() {
                    @Override
                    public void handleUpgrade(StreamConnection streamConnection, HttpServerExchange exchange) {
                        OptionMap undertowOptions = exchange.getConnection().getUndertowOptions();
                        Http2Channel channel = new Http2Channel(streamConnection, exchange.getConnection().getBufferPool(), null, false, true, settingsFrame, undertowOptions);
                        Http2ReceiveListener receiveListener = new Http2ReceiveListener(new HttpHandler() {
                            @Override
                            public void handleRequest(HttpServerExchange exchange) throws Exception {
                                //if this header is present we don't actually process the rest of the handler chain
                                //as the request was only to create the initial request
                                if(exchange.getRequestHeaders().contains("X-HTTP2-connect-only")) {
                                    exchange.endExchange();
                                    return;
                                }
                                next.handleRequest(exchange);
                            }
                        }, undertowOptions, exchange.getConnection().getBufferSize(), null);
                        channel.getReceiveSetter().set(receiveListener);
                        receiveListener.handleInitialRequest(exchange, channel);
                        channel.resumeReceives();
                    }
                });
                return;
            }
        }
View Full Code Here

            this.listener = listener;
        }

        @Override
        public void handleEvent(StreamConnection channel) {
            Http2Channel http2Channel = new Http2Channel(channel, bufferPool, null, true, true, options);
            Http2ClientConnection http2ClientConnection = new Http2ClientConnection(http2Channel, true);

            listener.completed(http2ClientConnection);
        }
View Full Code Here

        }

    }

    private static Http2ClientConnection createHttp2Channel(StreamConnection connection, Pool<ByteBuffer> bufferPool, OptionMap options) {
        Http2Channel http2Channel = new Http2Channel(connection, bufferPool, null, true, false, options);
        return new Http2ClientConnection(http2Channel, false);
    }
View Full Code Here

        String existing = (String) sslEngine.getSession().getValue(PROTOCOL_KEY);
        //resuming an existing session, no need for ALPN
        if (existing != null) {
            UndertowLogger.REQUEST_LOGGER.debug("Resuming existing session, not doing NPN negotiation");
            if (existing.equals(HTTP2)) {
                Http2Channel sc = new Http2Channel(channel, bufferPool, new ImmediatePooled<>(ByteBuffer.wrap(new byte[0])), false, false, undertowOptions);
                sc.getReceiveSetter().set(new Http2ReceiveListener(rootHandler, getUndertowOptions(), bufferSize));
                sc.resumeReceives();
            } else {
                if (delegate == null) {
                    UndertowLogger.REQUEST_IO_LOGGER.couldNotInitiateHttp2Connection();
                    IoUtils.safeClose(channel);
                    return;
View Full Code Here

                    }
                    buffer.getResource().flip();
                    if (HTTP2.equals(selected)) {

                        //cool, we have a Http2 connection.
                        Http2Channel channel = new Http2Channel(this.channel, bufferPool, buffer, false, false, undertowOptions);
                        Integer idleTimeout = undertowOptions.get(UndertowOptions.IDLE_TIMEOUT);
                        if (idleTimeout != null && idleTimeout > 0) {
                            channel.setIdleTimeout(idleTimeout);
                        }
                        free = false;
                        channel.getReceiveSetter().set(new Http2ReceiveListener(rootHandler, getUndertowOptions(), bufferSize));
                        channel.resumeReceives();
                        return;
                    } else if (HTTP_1_1.equals(selected) || res > 0) {
                        if (delegate == null) {
                            UndertowLogger.REQUEST_IO_LOGGER.couldNotInitiateHttp2Connection();
                            IoUtils.safeClose(channel);
                            return;
                        }
                        channel.getSourceChannel().setReadListener(null);
                        if (res > 0) {
                            PushBackStreamSourceConduit pushBackStreamSourceConduit = new PushBackStreamSourceConduit(channel.getSourceChannel().getConduit());
                            channel.getSourceChannel().setConduit(pushBackStreamSourceConduit);
                            pushBackStreamSourceConduit.pushBack(buffer);
                            free = false;
                        }
                        delegate.handleEvent(channel);
                        return;
                    } else if (res == 0) {
                        channel.getSourceChannel().resumeReads();
                        return;
                    }
                }

            } catch (IOException e) {
View Full Code Here

                final ByteBuffer settingsFrame = FlexBase64.decode(settings);
                exchange.upgradeChannel(new HttpUpgradeListener() {
                    @Override
                    public void handleUpgrade(StreamConnection streamConnection, HttpServerExchange exchange) {
                        OptionMap undertowOptions = exchange.getConnection().getUndertowOptions();
                        Http2Channel channel = new Http2Channel(streamConnection, exchange.getConnection().getBufferPool(), null, false, true, settingsFrame, undertowOptions);
                        Http2ReceiveListener receiveListener = new Http2ReceiveListener(new HttpHandler() {
                            @Override
                            public void handleRequest(HttpServerExchange exchange) throws Exception {
                                //if this header is present we don't actually process the rest of the handler chain
                                //as the request was only to create the initial request
                                if(exchange.getRequestHeaders().contains("X-HTTP2-connect-only")) {
                                    exchange.endExchange();
                                    return;
                                }
                                next.handleRequest(exchange);
                            }
                        }, undertowOptions, exchange.getConnection().getBufferSize());
                        channel.getReceiveSetter().set(receiveListener);
                        receiveListener.handleInitialRequest(exchange, channel);
                        channel.resumeReceives();
                    }
                });
                return;
            }
        }
View Full Code Here

        }

    }

    private static Http2ClientConnection createHttp2Channel(StreamConnection connection, Pool<ByteBuffer> bufferPool, OptionMap options) {
        Http2Channel http2Channel = new Http2Channel(connection, bufferPool, null, true, false, options);
        return new Http2ClientConnection(http2Channel, false);
    }
View Full Code Here

        }

    }

    private static Http2ClientConnection createHttp2Channel(StreamConnection connection, Pool<ByteBuffer> bufferPool, OptionMap options) {
        Http2Channel http2Channel = new Http2Channel(connection, bufferPool, null, true, false, options);
        return new Http2ClientConnection(http2Channel, false);
    }
View Full Code Here

TOP

Related Classes of io.undertow.protocols.http2.Http2RstStreamSinkChannel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.