if(upgrade != null && upgrade.equals(Http2Channel.CLEARTEXT_UPGRADE_STRING)) {
String settings = exchange.getRequestHeaders().getFirst("HTTP2-Settings");
if(settings != null) {
//required by spec
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() {