From 0ba30c0b17a3b551d29276884f1f1e69e81c1918 Mon Sep 17 00:00:00 2001 From: RayDNoper Date: Fri, 22 Dec 2023 11:12:51 +0200 Subject: [PATCH] Update cookie to ordered map --- .../ruuter/domain/steps/ReturnStep.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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 c225ecb..e1453cf 100644 --- a/src/main/java/ee/buerokratt/ruuter/domain/steps/ReturnStep.java +++ b/src/main/java/ee/buerokratt/ruuter/domain/steps/ReturnStep.java @@ -49,16 +49,17 @@ private Map formatHeaders(DslInstance di) { private Map.Entry addDefaultCookies(Map.Entry entry, DslInstance di) { if ("Set-Cookie".equals(entry.getKey())) { - if (!((HashMap) entry.getValue()).containsKey("Path")) - ((HashMap) entry.getValue()).put("Path", "/" ); + LinkedHashMap cookie = new LinkedHashMap<>((HashMap) entry.getValue()); + if (!cookie.containsKey("Path")) + cookie.put("Path", "/" ); - if (!((HashMap) entry.getValue()).containsKey("HttpOnly")) - ((HashMap) entry.getValue()).put("HttpOnly", true); - - if (!((HashMap) entry.getValue()).containsKey("SetSecure")) - ((HashMap) entry.getValue()).put("Secure", true); + if (!cookie.containsKey("HttpOnly")) + cookie.put("HttpOnly", true); + if (!cookie.containsKey("SetSecure")) + cookie.put("Secure", true); + entry.setValue(cookie); } return entry; }