Fork me on GitHub
#pedestal
<
2019-02-18
>
souenzzo18:02:24

Hello I'm using context-configurator to enable gzip, but it works just on "public" routes. I use csrf, so my get's are public and post's private

::http/enable-csrf       {}
 ::http/enable-session    {}
On get's, gzip works, on post's not My context config:
(defn context-configurator
  [^ServletContextHandler context]
  (let [gzip-handler (GzipHandler.)]
    (.setExcludedAgentPatterns gzip-handler (make-array String 0))
    (.setGzipHandler context gzip-handler))
  context)
https://github.com/pedestal/pedestal/blob/master/samples/servlet-filters-gzip/src/gzip/service.clj#L61

ddeaguiar18:02:08

@souenzzo, by private you mean that the csrf token is required?

ddeaguiar18:02:34

Hm, I’d expect that to behave similarly. I’d explore that further. If you have a minimal project reproducing the issue that would help.

👍 5
souenzzo19:02:31

is there any quick(dirty) workaround for this problem?

ddeaguiar19:02:42

I don’t know. I don’t understand why csrf would interfere with compression and my gut feeling is that it’s a red herring

👍 5
ddeaguiar19:02:19

@souenzzo I think I know what it is

ddeaguiar19:02:57

includedMethods
List of HTTP methods to compress. If not set, only GET requests are compressed.

ddeaguiar19:02:19

@souenzzo try specifying POST as an included method

souenzzo19:02:16

Nice! Working with (.addIncludedMethods gzip-handler (into-array ["GET" "POST"])) Should I do a PR to add a comment with this link in the example? or you can add?

ddeaguiar19:02:24

If you create a PR that would be great!

👍 5
souenzzo19:02:13

Thanks @U0FL657GR 😉 My POST respose goes from 5M to 300K