Search code examples
httppostclojurenoir

Can you set the size limit of a post request in header?


I'm trying to make a post request to my noir server but I have too many parameters and the server just responds with 413 status code. I was wondering if I could raise the character limit for the post request. I read it's possible with other services like What is the size limit of a post request? and Clojure/Ring: Using the ring jetty adapter, large requests give me a 413: FULL HEAD error.

Thanks!


Solution

  • noir.server/start accepts a map of options as a second argument (which is itself optional). If this map contains an entry with a key of :jetty-options, the value at that key is passed as the options argument to ring.adapter.jetty/run-jetty.

    So, you can say something like

    (server/start 8080 {:jetty-options {:configurator ...}})
    

    where the value at the :configurator key is as described in my answer to the Clojure/Ring: Using the ring jetty adapter, large requests give me a 413: FULL HEAD error. question you link to:

    ;;; reproducing here for convenience
    (fn [jetty]
      (doseq [connector (.getConnectors jetty)]
        (.setHeaderBufferSize connector header-buffer-size)))
    

    (header-buffer-size being the name of a Var storing a value you're happy with).