private HttpResponse addStickySessionIdentifier(HttpResponse httpResponse, Origin origin) { if (this.loadBalancer instanceof StickySessionLoadBalancingStrategy) { int maxAge = backendService.stickySessionConfig().stickySessionTimeoutSeconds(); return httpResponse.newBuilder() .addCookie(newStickySessionCookie(id, origin.id(), maxAge)) .build(); } else { return httpResponse; } }
/** * Adds a response cookie (adds a new Set-Cookie header). * * @param name cookie name * @param value cookie value * @return {@code this} */ public Builder addCookie(String name, String value) { return addCookie(HttpCookie.cookie(name, value)); }