aleph

valerauko 2024-02-08T05:17:50.079569Z

I'm trying to do the following: 1. upon receiving a http request (server side) 2. send a request to an upstream service with aleph client 3. there will be one or more cookies set in the response 4. I want to pass on these cookies (without using their values at all on the server side) and add a few more Does aleph provide some utilities to handle this?

Matthew Davidson 2024-02-08T10:31:48.940609Z

Not sure why that didn't work off the top of my head, but 99% of the cookie code is in a.h.client-middleware , so I'd look there. They're tagged :no-doc, but are public. In particular, look at aleph.http.client-middleware/add-cookie-header, aleph.http.client-middleware/merge-cookies and aleph.http.client-middleware/decode-set-cookie-header . One of those might be what you're looking for?

valerauko 2024-02-08T11:04:39.677169Z

It didn't work because the (:set-cookie headers) is a string (the cookies concatenated with comma) not a vector

Matthew Davidson 2024-02-08T11:55:49.114849Z

Yeah, that fits with the spec. Cookie headers are unusual in having a substructure.

Matthew Davidson 2024-02-08T11:56:47.363289Z

(Well, not THAT unusual, but still)

valerauko 2024-02-08T12:00:44.560219Z

Yet if I concat-join my new cookies onto that set-cookie string it sends only one weird big set-cookie header instead of each separately

valerauko 2024-02-08T05:19:40.351129Z

My idea was something like

(let [response @(fetch upstream)
      additional-cookies ["foo=bar" "a=b"]]
  {:status 200
   :headers (update (:headers response) "set-cookie" concat additional-cookies})
but this method did not work.