in zuul-sample/src/main/java/com/netflix/zuul/sample/filters/outbound/ZuulResponseFilter.java [65:112]
public HttpResponseMessage apply(HttpResponseMessage response) {
SessionContext context = response.getContext();
if (SEND_RESPONSE_HEADERS.get()) {
Headers headers = response.getHeaders();
StatusCategory statusCategory = StatusCategoryUtils.getStatusCategory(response);
if (statusCategory != null) {
headers.set(X_ZUUL_STATUS, statusCategory.name());
}
RequestAttempts attempts = RequestAttempts.getFromSessionContext(response.getContext());
String headerStr = "";
if (attempts != null) {
headerStr = attempts.toString();
}
headers.set(X_ZUUL_PROXY_ATTEMPTS, headerStr);
headers.set(X_ZUUL, "zuul");
headers.set(
X_ZUUL_INSTANCE,
System.getenv("EC2_INSTANCE_ID") != null ? System.getenv("EC2_INSTANCE_ID") : "unknown");
headers.set(CONNECTION, KEEP_ALIVE);
headers.set(X_ORIGINATING_URL, response.getInboundRequest().reconstructURI());
if (response.getStatus() >= 400 && context.getError() != null) {
Throwable error = context.getError();
headers.set(
X_ZUUL_ERROR_CAUSE,
error instanceof ZuulException ? ((ZuulException) error).getErrorCause() : "UNKNOWN_CAUSE");
}
if (response.getStatus() >= 500) {
logger.info("Passport: {}", CurrentPassport.fromSessionContext(context));
}
if (logger.isDebugEnabled()) {
logger.debug("Filter execution summary :: {}", context.getFilterExecutionSummary());
}
}
if (context.debugRequest()) {
Debug.getRequestDebug(context).forEach(s -> logger.info("REQ_DEBUG: {}", s));
Debug.getRoutingDebug(context).forEach(s -> logger.info("ZUUL_DEBUG: {}", s));
}
return response;
}