Skip to content

Commit

Permalink
only compress responses longer than 200 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejs committed Sep 14, 2010
1 parent e9ac1ed commit 794167a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ring/middleware/gzip.clj
Expand Up @@ -14,8 +14,9 @@
(defn wrap-gzip [handler]
(fn [req]
(let [resp (handler req)]
(if (and (not ((resp :headers) "content-encoding"))
(string? (resp :body)))
(if (and (not ((get resp :headers {}) "content-encoding"))
(string? (resp :body))
(> (count (resp :body)) 200))
(let [accepts (get (req :headers) "accept-encoding" "")
match (re-find #"(gzip|\*)(;q=((0|1)(.\d+)?))?" accepts)]
(if (and match (not (contains? #{"0" "0.0" "0.00" "0.000"}
Expand Down

0 comments on commit 794167a

Please sign in to comment.