Skip to content

Commit

Permalink
Merge pull request #493 from NoahTheDuke/nb/partitioned-cookies
Browse files Browse the repository at this point in the history
Add support for Partitioned/CHIPS cookies
  • Loading branch information
weavejester committed Jan 24, 2024
2 parents 76e5d29 + 6e8dee8 commit ca7b259
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ring-core/src/ring/middleware/cookies.clj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
(def ^:private set-cookie-attrs
{:domain "Domain", :max-age "Max-Age", :path "Path"
:secure "Secure", :expires "Expires", :http-only "HttpOnly"
:same-site "SameSite"})
:same-site "SameSite", :partitioned "Partitioned"})

(def ^:private same-site-values
{:strict "Strict", :lax "Lax", :none "None"})
Expand Down
7 changes: 7 additions & 0 deletions ring-core/test/ring/middleware/test/cookies.clj
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@
(is (= {"Set-Cookie" (list "a=b" "c=d")}
(:headers resp)))))

(deftest wrap-cookies-set-partitioned
(let [response {:cookies {"a" {:value "foo" :partitioned true}}}
handler (constantly response)
resp ((wrap-cookies handler) {})]
(is (= {"Set-Cookie" #{"a=foo" "Partitioned"}}
(split-set-cookie (:headers resp))))))

(deftest wrap-cookies-invalid-attrs
(let [response {:cookies {"a" {:value "foo" :invalid true}}}
handler (wrap-cookies (constantly response))]
Expand Down

0 comments on commit ca7b259

Please sign in to comment.