When I was calling the jetty handler directly, I was able to pass in a configurator like so:
(def header-buffer-size 8388608)
(defn start [port]
(ring/run-jetty
(var app)
{:port port
:join? false
:host "127.0.0.1"
:configurator
(fn [jetty]
(doseq [connector (.getConnectors jetty)]
(.setHeaderBufferSize connector header-buffer-size)))}))
I had to do this because I kept getting a FULL HEAD error when posting. Now I refactored things to use > lein ring server directly, which gets called from the command line.
> lein ring server
This uses some configuration specified in my project.clj:
:ring {:handler caribou.api.core/app
:servlet-name "caribou-api"
:init caribou.api.core/init
:port 33443}
This works great, but now I am getting the FULL HEAD issue again. So I tried to add a configurator in there:
:ring {:handler caribou.api.core/app
:servlet-name "caribou-api"
:init caribou.api.core/init
:configurator
(fn [jetty]
(doseq [connector (.getConnectors jetty)]
(.setHeaderBufferSize connector 8388608)))
:port 33443})
And this fails with this stacktrace:
Exception in thread "main" java.lang.ClassCastException:
clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
at ring.adapter.jetty$run_jetty.invoke(jetty.clj:66)
at ring.server.standalone$serve$fn__833.invoke(standalone.clj:78)
at ring.server.standalone$try_port.invoke(standalone.clj:12)
at ring.server.standalone$serve.doInvoke(standalone.clj:75)
at clojure.lang.RestFn.invoke(RestFn.java:423)
at ring.server.leiningen$serve.invoke(leiningen.clj:20)
I figured this had to do with putting the function directly in the map like that, so I defined it outside the project (in caribou.api.core) and tried referring to it like I do the rest of the functions defined elsewhere:
;; in caribou/api/core.clj
(def header-buffer-size 8388608)
(defn full-head-avoidance
[jetty]
(doseq [connector (.getConnectors jetty)]
(.setHeaderBufferSize connector header-buffer-size)))
;; in project.clj
:ring {:handler caribou.api.core/app
:servlet-name "caribou-api"
:init caribou.api.core/init
:configurator caribou.api.core/full-head-avoidance
:port 33443})
This spins up the app, but I still get the 413: FULL HEAD error when posting. Any ideas? Thanks!