use of org.webpieces.ctx.api.OverwritePlatformResponse in project webpieces by deanhiller.
the class CompressionChunkingHandle method process.
@Override
public XFuture<StreamWriter> process(Http2Response response) {
if (lastResponseSent != null)
throw new IllegalStateException("You already sent a response. " + "do not call Actions.redirect or Actions.render more than once. previous response=" + lastResponseSent + " 2nd response=" + response);
lastResponseSent = response;
Compression compression = checkForCompression(response);
ChunkedStream chunkedStream = new ChunkedStream(webSettings.getMaxBodySizeToSend());
Http2Response finalResp = response;
if (Current.isContextSet()) {
// in some exceptional cases like incoming cookies failing to parse, there will be no context
List<OverwritePlatformResponse> callbacks = Current.getContext().getCallbacks();
for (OverwritePlatformResponse callback : callbacks) {
finalResp = (Http2Response) callback.modifyOrReplace(finalResp);
}
}
boolean closeAfterResponding = false;
if (closeAfterResponding(originalRequest))
closeAfterResponding = true;
boolean shouldClose = closeAfterResponding;
return handler.process(response).thenApply(w -> possiblyClose(shouldClose, response, w)).thenApply(w -> new ProxyStreamWriter(shouldClose, compression, chunkedStream, w));
}
Aggregations