in zuul-core/src/main/java/com/netflix/zuul/netty/server/ClientRequestReceiver.java [217:286]
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (evt instanceof CompleteEvent) {
CompleteReason reason = ((CompleteEvent) evt).getReason();
if (zuulRequest != null) {
zuulRequest.getContext().cancel();
zuulRequest.disposeBufferedBody();
CurrentPassport passport = CurrentPassport.fromSessionContext(zuulRequest.getContext());
if ((passport != null) && (passport.findState(PassportState.OUT_RESP_LAST_CONTENT_SENT) == null)) {
// Only log this state if the response does not seem to have completed normally.
passport.add(PassportState.IN_REQ_CANCELLED);
}
}
if (reason == CompleteReason.INACTIVE && zuulRequest != null) {
// Client closed connection prematurely.
StatusCategoryUtils.setStatusCategory(
zuulRequest.getContext(), ZuulStatusCategory.FAILURE_CLIENT_CANCELLED);
}
if (reason == CompleteReason.PIPELINE_REJECT && zuulRequest != null) {
StatusCategoryUtils.setStatusCategory(
zuulRequest.getContext(), ZuulStatusCategory.FAILURE_CLIENT_PIPELINE_REJECT);
}
if (reason != CompleteReason.SESSION_COMPLETE && zuulRequest != null) {
SessionContext zuulCtx = zuulRequest.getContext();
if (clientRequest != null) {
if (LOG.isInfoEnabled()) {
// With http/2, the netty codec closes/completes the stream immediately after writing the
// lastcontent
// of response to the channel, which causes this CompleteEvent to fire before we have cleaned up
// state. But
// thats ok, so don't log in that case.
if (Objects.equals(zuulRequest.getProtocol(), "HTTP/2")) {
LOG.debug(
"Client {} request UUID {} to {} completed with reason = {}, {}",
clientRequest.method(),
zuulCtx.getUUID(),
clientRequest.uri(),
reason.name(),
ChannelUtils.channelInfoForLogging(ctx.channel()));
}
}
}
if (zuulCtx.debugRequest()) {
LOG.debug("Endpoint = {}", zuulCtx.getEndpoint());
dumpDebugInfo(Debug.getRequestDebug(zuulCtx));
dumpDebugInfo(Debug.getRoutingDebug(zuulCtx));
}
}
if (zuulRequest == null) {
Spectator.globalRegistry()
.counter("zuul.client.complete.null", "reason", String.valueOf(reason))
.increment();
}
clientRequest = null;
zuulRequest = null;
}
super.userEventTriggered(ctx, evt);
if (evt instanceof CompleteEvent) {
Channel channel = ctx.channel();
channel.attr(ATTR_ZUUL_REQ).set(null);
channel.attr(ATTR_ZUUL_RESP).set(null);
channel.attr(ATTR_LAST_CONTENT_RECEIVED).set(null);
}
}