Skip to content

Commit

Permalink
Update cookie to ordered map
Browse files Browse the repository at this point in the history
  • Loading branch information
RayDNoper committed Dec 22, 2023
1 parent 1e753c4 commit 0ba30c0
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/main/java/ee/buerokratt/ruuter/domain/steps/ReturnStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,17 @@ private Map<String, String> formatHeaders(DslInstance di) {

private Map.Entry<String, Object> addDefaultCookies(Map.Entry<String, Object> entry, DslInstance di) {
if ("Set-Cookie".equals(entry.getKey())) {
if (!((HashMap<String, Object>) entry.getValue()).containsKey("Path"))
((HashMap<String, Object>) entry.getValue()).put("Path", "/" );
LinkedHashMap<String, Object> cookie = new LinkedHashMap<>((HashMap<String, Object>) entry.getValue());
if (!cookie.containsKey("Path"))
cookie.put("Path", "/" );

if (!((HashMap<String, Object>) entry.getValue()).containsKey("HttpOnly"))
((HashMap<String, Object>) entry.getValue()).put("HttpOnly", true);

if (!((HashMap<String, Object>) entry.getValue()).containsKey("SetSecure"))
((HashMap<String, Object>) 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;
}
Expand Down

0 comments on commit 0ba30c0

Please sign in to comment.