tailrecursion / ring-proxy

HTTP proxy ring middleware for Clojure web applications.
47 stars 14 forks source link

use clj-http's wrap-cookies instead of ring's because formats have diverged #15

Open bmaddy opened 9 years ago

bmaddy commented 9 years ago

This switches to use clj-http's wrap-cookies instead of ring's because their formats have diverged. clj-http returns cookies something like this:

{:discard true, :expires , :path /, :version 0, :value ...}

but ring no longer accepts :discard and :version as shown here: https://github.com/ring-clojure/ring/commit/c05004fcb2227e75f2299ac7e6d8d9a4aefdb002#diff-c055e0aeef031084c68bf6da304ed4f7L25

This leads to the following error when there is cookie info in the response:

java.lang.AssertionError: Assert failed: (every? valid-attr? attrs)
webmonarch commented 8 years ago

:+1: my understanding of all of the cookie fields is a little rusty, but I do think for a proxy server, being a bit "looser" with spec adherence makes sense.

Alternatively, one could delete the keys in the tailrecursion.ring-proxy/prepare-cookies function. (which I also did successfully for my use-cases).

ghost commented 8 years ago

Just curious @webmonarch is there some way to override this implementation easily as you mentioned above? I want to make sure I'm not missing a neat piece of clojure. The only thing I can think of is a fork in my own repo to implement the desired cookie behavior.

webmonarch commented 8 years ago

hey @aft-luke, yeah, nothing neat that I know of. I forked for our internal projects. The code is pretty small so a good ol' copy + paste would probably work too.

Good luck!

ghost commented 8 years ago

Thanks @webmonarch. I ended up writing my own handler that's 80% copy/paste as well.