in zuul-core/src/main/java/com/netflix/netty/common/HttpServerLifecycleChannelHandler.java [61:94]
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
if (msg instanceof HttpResponse) {
ctx.channel().attr(ATTR_HTTP_RESP).set((HttpResponse) msg);
}
try {
super.write(ctx, msg, promise);
} finally {
if (msg instanceof LastHttpContent) {
boolean dontFireCompleteYet = false;
if (msg instanceof HttpResponse) {
// Handle case of 100 CONTINUE, where server sends an initial 100 status response to indicate to
// client
// that it can continue sending the initial request body.
// ie. in this case we don't want to consider the state to be COMPLETE until after the 2nd
// response.
if (Objects.equals(((HttpResponse) msg).status(), HttpResponseStatus.CONTINUE)) {
dontFireCompleteYet = true;
}
}
if (!dontFireCompleteYet) {
if (promise.isDone()) {
fireCompleteEventIfNotAlready(ctx, CompleteReason.SESSION_COMPLETE);
} else {
promise.addListener(future -> {
fireCompleteEventIfNotAlready(ctx, CompleteReason.SESSION_COMPLETE);
});
}
}
}
}
}