HttpString transferEncoding = Headers.IDENTITY;
if (transferEncodingHeader != null) {
transferEncoding = new HttpString(transferEncodingHeader);
}
if (transferEncodingHeader != null && !transferEncoding.equals(Headers.IDENTITY)) {
ConduitStreamSourceChannel sourceChannel = exchange.getConnection().getChannel().getSourceChannel();
sourceChannel.setConduit(new ChunkedStreamSourceConduit(sourceChannel.getConduit(), exchange, chunkedDrainListener(exchange), maxEntitySize(exchange)));
} else if (contentLengthHeader != null) {
final long contentLength;
contentLength = Long.parseLong(contentLengthHeader);
if (contentLength == 0L) {
log.trace("No content, starting next request");
// no content - immediately start the next request, returning an empty stream for this one
exchange.terminateRequest();
} else {
// fixed-length content - add a wrapper for a fixed-length stream
ConduitStreamSourceChannel sourceChannel = exchange.getConnection().getChannel().getSourceChannel();
sourceChannel.setConduit(fixedLengthStreamSourceConduitWrapper(contentLength, sourceChannel.getConduit(), exchange));
}
} else if (transferEncodingHeader != null) {
if (transferEncoding.equals(Headers.IDENTITY)) {
log.trace("Connection not persistent (no content length and identity transfer encoding)");
// make it not persistent