File tree 2 files changed +8
-7
lines changed
2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 11
11
12
12
; only available on JDK7
13
13
(def ^:private flushable-gzip?
14
- (->> (clojure.reflect/reflect GZIPOutputStream)
15
- :members
16
- (some (comp '#{[java.io.OutputStream boolean]} :parameter-types ))))
14
+ (delay ( ->> (clojure.reflect/reflect GZIPOutputStream)
15
+ :members
16
+ (some (comp '#{[java.io.OutputStream boolean]} :parameter-types ) ))))
17
17
18
18
; only proxying here so we can specialize io/copy (which ring uses to transfer
19
19
; InputStream bodies to the servlet response) for reading from the result of
38
38
(defn piped-gzipped-input-stream [in]
39
39
(let [pipe-in (piped-gzipped-input-stream* )
40
40
pipe-out (PipedOutputStream. pipe-in)]
41
- (future ; new thread to prevent blocking deadlock
42
- (with-open [out (if flushable-gzip?
41
+ ; separate thread to prevent blocking deadlock
42
+ (future
43
+ (with-open [out (if @flushable-gzip?
43
44
(GZIPOutputStream. pipe-out true )
44
45
(GZIPOutputStream. pipe-out))]
45
46
(if (seq? in)
66
67
(not (get-in resp [:headers " Content-Encoding" ]))
67
68
(or
68
69
(and (string? body) (> (count body) 200 ))
69
- (and (seq? body) flushable-gzip?)
70
+ (and (seq? body) @ flushable-gzip?)
70
71
(instance? InputStream body)
71
72
(instance? File body)))
72
73
(let [accepts (get-in req [:headers " accept-encoding" ] " " )
Original file line number Diff line number Diff line change 52
52
:headers {}}))
53
53
resp (app (accepting " gzip" ))]
54
54
(is (= 200 (:status resp)))
55
- (if @#'ring.middleware.gzip/flushable-gzip?
55
+ (if @@ #'ring.middleware.gzip/flushable-gzip?
56
56
(do
57
57
(println " Running on JDK7+, testing gzipping of seq response bodies." )
58
58
(is (= " gzip" (encoding resp)))
You can’t perform that action at this time.
0 commit comments