diff --git a/src/main/java/ee/buerokratt/ruuter/domain/steps/ReturnStep.java b/src/main/java/ee/buerokratt/ruuter/domain/steps/ReturnStep.java index e1453cfd..0a86d4f2 100644 --- a/src/main/java/ee/buerokratt/ruuter/domain/steps/ReturnStep.java +++ b/src/main/java/ee/buerokratt/ruuter/domain/steps/ReturnStep.java @@ -47,17 +47,18 @@ private Map formatHeaders(DslInstance di) { .collect(toMap(Entry::getKey, this::entryValueToHeaderString)); } + private void addToCookie(LinkedHashMap cookie, String key, Object value) { + if (!cookie.containsKey(key)) + cookie.put(key, value); + } private Map.Entry addDefaultCookies(Map.Entry entry, DslInstance di) { if ("Set-Cookie".equals(entry.getKey())) { LinkedHashMap cookie = new LinkedHashMap<>((HashMap) entry.getValue()); - if (!cookie.containsKey("Path")) - cookie.put("Path", "/" ); - - if (!cookie.containsKey("HttpOnly")) - cookie.put("HttpOnly", true); - if (!cookie.containsKey("SetSecure")) - cookie.put("Secure", true); + addToCookie(cookie, "Path", "/"); + addToCookie(cookie, "HttpOnly", true); + addToCookie(cookie, "Secure", true); + addToCookie(cookie, "Max-Age", 28800); entry.setValue(cookie); }