Unable to add cookies to the cookie store
Nobody has claimed this yet.
- Dominant language
- Clojure
- Stars
- 1.8k
- Forks
- 410
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to manually add a cookie to a cookie store, but I'm running into some problems.
Running the following code results in an empty set
(def my-cookie-store (clj-http.cookies/cookie-store))
(clj-http.cookies/add-cookie my-cookie-store (clj-http.cookies/to-basic-client-cookie ["foo" {:value "bar"}]))
(clojure.pprint/pprint (clj-http.cookies/get-cookies my-cookie-store))
=> {}
Whilst running the following results in the expected set of 1 cookie.
(def my-cookie-store (clj-http.cookies/cookie-store))
(clj-http.cookies/add-cookie my-cookie-store (org.apache.http.impl.cookie.BasicClientCookie2. "foo" "bar"))
(clojure.pprint/pprint (clj-http.cookies/get-cookies my-cookie-store))
=> {"foo" {:discard true, :secure false, :value "bar", :version 0}}
Am I using the add-cookie, or to-basic-client-cookie, wrong? Because as far as I understand the source code, both versions of my code should achieve the same results.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the add-cookie and to-basic-client-cookie calls shown in the issue, then compare the cookie object produced by the conversion with the BasicClientCookie2 instance. Confirm why get-cookies returns an empty map for the converted cookie and consider the issue complete when both paths produce the same stored result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100