//we have a request
final Http2StreamSourceChannel dataChannel = (Http2StreamSourceChannel) frame;
final Http2ServerConnection connection = new Http2ServerConnection(channel, dataChannel, undertowOptions, bufferSize, rootHandler);
final HttpServerExchange exchange = new HttpServerExchange(connection, dataChannel.getHeaders(), dataChannel.getResponseChannel().getHeaders(), maxEntitySize);
dataChannel.setMaxStreamSize(maxEntitySize);
exchange.setRequestScheme(exchange.getRequestHeaders().getFirst(SCHEME));
exchange.setProtocol(Protocols.HTTP_1_1);
exchange.setRequestMethod(Methods.fromString(exchange.getRequestHeaders().getFirst(METHOD)));
exchange.getRequestHeaders().put(Headers.HOST, exchange.getRequestHeaders().getFirst(AUTHORITY));
final String path = exchange.getRequestHeaders().getFirst(PATH);
Connectors.setExchangeRequestPath(exchange, path, encoding,decode, allowEncodingSlash, decodeBuffer);
SSLSession session = channel.getSslSession();
if(session != null) {
connection.setSslSessionInfo(new Http2SslSessionInfo(channel));
}
dataChannel.getResponseChannel().setCompletionListener(new ChannelListener<Http2DataStreamSinkChannel>() {
@Override
public void handleEvent(Http2DataStreamSinkChannel channel) {
Connectors.terminateResponse(exchange);
}
});
if(!dataChannel.isOpen()) {
Connectors.terminateRequest(exchange);
} else {
dataChannel.setCompletionListener(new ChannelListener<Http2StreamSourceChannel>() {
@Override
public void handleEvent(Http2StreamSourceChannel channel) {
Connectors.terminateRequest(exchange);
}
});
}
if(connectorStatistics != null) {
connectorStatistics.setup(exchange);
}
//TODO: we should never actually put these into the map in the first place
exchange.getRequestHeaders().remove(AUTHORITY);
exchange.getRequestHeaders().remove(PATH);
exchange.getRequestHeaders().remove(SCHEME);
exchange.getRequestHeaders().remove(METHOD);
Connectors.executeRootHandler(rootHandler, exchange);
}