}
buffer.getResource().flip();
if (SPDY_3.equals(selected) || SPDY_3_1.equals(selected)) {
//cool, we have a spdy connection.
SpdyChannel channel = new SpdyChannel(this.channel, bufferPool, buffer, heapBufferPool, false);
Integer idleTimeout = undertowOptions.get(UndertowOptions.IDLE_TIMEOUT);
if (idleTimeout != null && idleTimeout > 0) {
channel.setIdleTimeout(idleTimeout);
}
free = false;
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()));
}
channel.getReceiveSetter().set(new SpdyReceiveListener(rootHandler, getUndertowOptions(), bufferSize, connectorStatistics));
channel.resumeReceives();
return;
} else if (HTTP_1_1.equals(selected) || res > 0) {
if (delegate == null) {
UndertowLogger.REQUEST_IO_LOGGER.couldNotInitiateSpdyConnection();
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) {