use of io.undertow.conduits.FinishableStreamSinkConduit in project undertow by undertow-io.
the class HttpTransferEncoding method handleExplicitTransferEncoding.
private static StreamSinkConduit handleExplicitTransferEncoding(HttpServerExchange exchange, StreamSinkConduit channel, ConduitListener<StreamSinkConduit> finishListener, HeaderMap responseHeaders, String transferEncodingHeader, boolean headRequest) {
HttpString transferEncoding = new HttpString(transferEncodingHeader);
if (transferEncoding.equals(Headers.CHUNKED)) {
if (headRequest) {
return channel;
}
Boolean preChunked = exchange.getAttachment(HttpAttachments.PRE_CHUNKED_RESPONSE);
if (preChunked != null && preChunked) {
return new PreChunkedStreamSinkConduit(channel, finishListener, exchange);
} else {
return new ChunkedStreamSinkConduit(channel, exchange.getConnection().getByteBufferPool(), true, !exchange.isPersistent(), responseHeaders, finishListener, exchange);
}
} else {
if (headRequest) {
return channel;
}
log.trace("Cancelling persistence because response is identity with no content length");
// make it not persistent - very unfortunate for the next request handler really...
exchange.setPersistent(false);
responseHeaders.put(Headers.CONNECTION, Headers.CLOSE.toString());
return new FinishableStreamSinkConduit(channel, terminateResponseListener(exchange));
}
}
Aggregations