final String contentLengthHeader = requestHeaders.getFirst(Headers.CONTENT_LENGTH);
final HttpServerConnection connection = exchange.getConnection();
ConduitStreamSinkChannel sinkChannel = connection.getChannel().getSinkChannel();
//if we are already using the pipelineing buffer add it to the exchange
PipelingBufferingStreamSinkConduit pipeliningBuffer = connection.getAttachment(PipelingBufferingStreamSinkConduit.ATTACHMENT_KEY);
if (pipeliningBuffer != null) {
pipeliningBuffer.setupPipelineBuffer(exchange);
}
ConduitStreamSourceChannel sourceChannel = connection.getChannel().getSourceChannel();
sourceChannel.setConduit(new ReadDataStreamSourceConduit(sourceChannel.getConduit(), connection));
boolean persistentConnection = persistentConnection(exchange, connectionHeader);
if (exchange.getRequestMethod().equals(Methods.GET)) {
if (persistentConnection
&& connection.getExtraBytes() != null
&& pipeliningBuffer == null
&& connection.getUndertowOptions().get(UndertowOptions.BUFFER_PIPELINED_DATA, false)) {
pipeliningBuffer = new PipelingBufferingStreamSinkConduit(connection.getOriginalSinkConduit(), connection.getBufferPool());
connection.putAttachment(PipelingBufferingStreamSinkConduit.ATTACHMENT_KEY, pipeliningBuffer);
pipeliningBuffer.setupPipelineBuffer(exchange);
}
// no content - immediately start the next request, returning an empty stream for this one
exchange.terminateRequest();
} else {
persistentConnection = handleRequestEncoding(exchange, transferEncodingHeader, contentLengthHeader, connection, pipeliningBuffer, persistentConnection);