diff --git a/project.clj b/project.clj index f781547e3..4c39642b6 100644 --- a/project.clj +++ b/project.clj @@ -197,7 +197,7 @@ [prismatic/schema "1.4.1"] [riddley "0.2.0"] [ring/ring-codec "1.3.0"] - [ring/ring-core "1.8.2"] + [ring/ring-core "1.15.3"] [ring/ring-mock "0.6.2"] [robert/hooke "1.3.0"] [timofreiberg/bultitude "0.3.1"] diff --git a/src/puppetlabs/puppetdb/http/command.clj b/src/puppetlabs/puppetdb/http/command.clj index 0d903ecb9..2ffc46a41 100644 --- a/src/puppetlabs/puppetdb/http/command.clj +++ b/src/puppetlabs/puppetdb/http/command.clj @@ -17,7 +17,7 @@ (:import (clojure.lang ExceptionInfo) (java.net HttpURLConnection) - (org.apache.commons.fileupload.util LimitedInputStream))) + (org.apache.commons.io.input BoundedInputStream))) (def min-supported-commands {"configure expiration" 1 @@ -124,13 +124,16 @@ ;; The drain is because ruby. i.e. if we closed the connection ;; without that, one of the ruby clients wouldn't handle the broken ;; pipe in a friendly way. - (proxy [LimitedInputStream] [stream max-size] - (raiseError [max-size count] + ;; + ;; Override onMaxLength which is called when + ;; the max count is reached during a read operation. + (proxy [BoundedInputStream] [stream max-size] + (onMaxLength [max-count read-count] ;; We don't trust skip; it appears to just invoke InputStream ;; skip which claims to allocate at least one buffer (of ;; unspecified size) per request. (loop [buf (byte-array (* 64 1024))] - (when (pos? (.read ^java.io.InputStream this buf)) + (when (pos? (.read ^java.io.InputStream stream buf)) (recur buf))) (throw (ex-info "" {:kind ::body-stream-overflow})))))