This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-10
Channels
- # announcements (3)
- # babashka (16)
- # beginners (41)
- # biff (4)
- # calva (14)
- # circleci (1)
- # clj-http (24)
- # clj-kondo (9)
- # clj-on-windows (31)
- # cljs-dev (52)
- # clojure (162)
- # clojure-australia (10)
- # clojure-europe (52)
- # clojure-nl (2)
- # clojure-spec (1)
- # clojure-uk (5)
- # clojurescript (40)
- # conjure (6)
- # core-async (3)
- # cursive (5)
- # datalevin (11)
- # datomic (7)
- # emacs (12)
- # etaoin (19)
- # events (1)
- # figwheel-main (17)
- # fulcro (4)
- # graalvm (3)
- # gratitude (13)
- # honeysql (8)
- # introduce-yourself (7)
- # london-clojurians (1)
- # off-topic (9)
- # polylith (9)
- # rdf (1)
- # re-frame (21)
- # releases (5)
- # remote-jobs (4)
- # sci (28)
- # shadow-cljs (15)
- # spacemacs (2)
- # vim (4)
- # xtdb (15)
May 10, 2022 8:23:08 AM org.apache.http.client.protocol.ResponseProcessCookies processCookies WARNING: Invalid cookie header: "Set-Cookie: AWSALB=LTy2kdai5cSMLrDecSgJBGmKDPDBTIYsW8Uky4skVcYsib8IOeNivSDURlsNo40qx2q296dErIJ0ar3/FbGy7wBZfaCFJY2M5XRUIgNsAC50nK0Y886/v42ha0WJ; Expires=Tue, 17 May 2022 12:23:09 GMT; Path=/". Invalid 'expires' attribute: Tue, 17 May 2022 12:23:09 GMT May 10, 2022 8:23:08 AM org.apache.http.client.protocol.ResponseProcessCookies processCookies WARNING: Invalid cookie header: "Set-Cookie: AWSALBCORS=LTy2kdai5cSMLrDecSgJBGmKDPDBTIYsW8Uky4skVcYsib8IOeNivSDURlsNo40qx2q296dErIJ0ar3/FbGy7wBZfaCFJY2M5XRUIgNsAC50nK0Y886/v42ha0WJ; Expires=Tue, 17 May 2022 12:23:09 GMT; Path=/; SameSite=None; Secure". Invalid 'expires' attribute: Tue, 17 May 2022 12:23:09 GMT
It looks like the cookie spec is hardcoded here in clj-http: https://github.com/dakrone/clj-http/blob/3.x/src/clj_http/cookies.clj#L13-L16 Do you use clj-http on the client you need it to process / set cookies on the client?
I am building a client application that will use Openapi to send updates to the server.
I'm not sure how to do it with clj-http but in https://github.com/elastic/support-diagnostics/issues/233 they suggest using this:
HttpClient httpClient = HttpClients.custom()
.setDefaultRequestConfig(RequestConfig.custom()
.setCookieSpec(CookieSpecs.STANDARD).build())
.build();
But redefine cookie-spec
?;; Cookies can be completely configurable with a custom spec by adding a
;; function to return a cookie spec for parsing the cookie. For example, if you
;; wanted to configure a spec provider to have a certain compatibility level:
(client/post ""
{:cookie-spec
(fn [http-context]
(println "generating a new cookie spec")
(.create
(org.apache.http.impl.cookie.RFC6265CookieSpecProvider.
org.apache.http.impl.cookie.RFC6265CookieSpecProvider$CompatibilityLevel/IE_MEDIUM_SECURITY
(PublicSuffixMatcherLoader/getDefault))
http-context))})
;; Or a version with relaxed compatibility
(client/post ""
{:cookie-spec
(fn [http-context]
(println "generating a new cookie spec")
(.create
(org.apache.http.impl.cookie.RFC6265CookieSpecProvider.
org.apache.http.impl.cookie.RFC6265CookieSpecProvider$CompatibilityLevel/RELAXED
(PublicSuffixMatcherLoader/getDefault))
http-context))})
I guess I just don't know Java well enough to know how to use this :cookie-spec to achive the answer the guy gave on github
Hmm, I got an expected answer?
(require '[clj-http.cookies :as http-cookies])
(http-cookies/decode-cookie
"Set-Cookie: AWSALB=LTy2kdai5cSMLrDecSgJBGmKDPDBTIYsW8Uky4skVcYsib8IOeNivSDURlsNo40qx2q296dErIJ0ar3/FbGy7wBZfaCFJY2M5XRUIgNsAC50nK0Y886/v42ha0WJ; Expires=Tue, 17 May 2022 12:23:09 GMT; Path=/")
;; => ["Set-Cookie: AWSALB" {:discard false, :expires #inst "2022-05-17T12:23:09.000-00:00", :path "/", :secure false, :value "LTy2kdai5cSMLrDecSgJBGmKDPDBTIYsW8Uky4skVcYsib8IOeNivSDURlsNo40qx2q296dErIJ0ar3/FbGy7wBZfaCFJY2M5XRUIgNsAC50nK0Y886/v42ha0WJ", :version 0}]
What you shared above I think should do the job.
It looks very similar to cookie-spec
function used by clj-http.
I would just use this:
(defn cookie-spec ^org.apache.http.cookie.CookieSpec [http-context]
(.create
(RFC6265CookieSpecProvider.)
http-context
#_(BasicHttpContext.)))
(http/get ""
{:cookie-spec cookie-spec})
Syntax error (IllegalArgumentException) compiling new at (C:\Users\benja\AppData\Local\Temp\form-init16040719483634482323.clj:8:5). Unable to resolve classname: RFC6265CookieSpecProvider
Oh, you need to import it first: here's my code: https://github.com/jumarko/clojure-experiments/blob/master/src/clojure_experiments/networking.clj#L96-L113 The import: https://github.com/jumarko/clojure-experiments/blob/master/src/clojure_experiments/networking.clj#L11-L13
Yea!! Thank you so much, I verified that the cookies made it to the cookie-store and I wasn't presented with any warnings.
I did see someone else in the Java world also ran into this issue here: https://github.com/elastic/support-diagnostics/issues/233