}
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) {