File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 5555 (.close gos)
5656 (.toByteArray baos))))
5757
58+ (defn- force-byte-array
59+ " force b as byte array if it is an InputStream."
60+ [b]
61+ (if (instance? java.io.InputStream b)
62+ (IOUtils/toByteArray b)
63+ b))
64+
5865(defn inflate
59- " Returns a zlib inflate'd version of the given byte array."
66+ " Returns a zlib inflate'd version of the given byte array or InputStream ."
6067 [b]
61- (when b
68+ (when-let [data-arr ( force-byte-array b)]
6269 (try
63- (IOUtils/toByteArray (InflaterInputStream. (ByteArrayInputStream. b )))
64- ; ; broken inflate implementation server-side,
70+ (IOUtils/toByteArray (InflaterInputStream. (ByteArrayInputStream. data-arr )))
71+ ; ; broken inflate implementation server-side
6572 ; ; see [http://stackoverflow.com/questions/3932117/handling-http
6673 ; ; -contentencoding-deflate]
6774 (catch java.util.zip.ZipException e
6875 (IOUtils/toByteArray
69- (InflaterInputStream. (ByteArrayInputStream. b )
76+ (InflaterInputStream. (ByteArrayInputStream. data-arr )
7077 (java.util.zip.Inflater. true )))))))
7178
7279(defn deflate
You can’t perform that action at this time.
0 commit comments