oliyh / martian

The HTTP abstraction library for Clojure/script, supporting OpenAPI, Swagger, Schema, re-frame and more
MIT License
525 stars 42 forks source link

Invalid cookie header #182

Closed MutableR closed 10 months ago

MutableR commented 10 months ago

I have this error: "Msg": "Invalid cookie header: \"Set-Cookie: **** ; Path=/; Domain=****; Expires=Thu, 10 Aug 2023 10:14:39 GMT; HttpOnly; Secure\". Invalid 'expires' attribute: Thu, 10 Aug 2023 10:14:39 GMT"

I remember this error fixed in clj-http setting :cookie-policy: none and/or :decode-cookies false in client. How can I change the cookie policy or disable the cookie decode in martian?

oliyh commented 10 months ago

Hi,

See the readme section on adding interceptors: https://github.com/oliyh/martian#global-behaviour

In your case, you can set the field on the request map (the request map is given to clj-http):

(def ignore-invalid-cookies
  {:name ::ignore-invalid-cookies
   :enter (fn [ctx]
            (assoc-in ctx [:request :cookie-policy] :none))})

Hope this helps!

MutableR commented 10 months ago

@oliyh It works! Thank you. I use interceptors, but it didn't seem obvious to me as a user.

Perhaps this should be included in the documentation (my own opinion) or add more examples of usage. Perhaps someone will come across such a question too and will look for a solution as I did before I wrote to the issue.

MutableR commented 10 months ago

@oliyh Your library is great, I enjoy using it. But it was nice to see more examples or use cases. Thank you for your hard work.