     # Collect Response Body
     buffer.pause()
     
-    gzipped = false
+    encoding = ContentEncoding.IDENTITY
 
     transformResponse = (statusCode, reason, headers) ->
-        if gzipped
-            unzip = Zlib.createUnzip()
+        if encoding != ContentEncoding.IDENTITY
+            
+            if encoding == ContentEncoding.GZIP
+                unzip = Zlib.createGunzip()
+            else
+                unzip = Zlib.createInflate()
+
             buffer.pipe(unzip).pipe(newRes)
         else
             buffer.pipe(newRes)

Zlib = require 'zlib'

captureResponse = require './../capture'

exports.gunZip = gunZip = (req, res, next) ->
    req.headers['accept-encoding'] = 'gzip, deflate'

    res.writeHead = (statusCode, reason..., headers={}) ->
        reason = reason[0]
        
        encoding = ContentEncoding.parse headers['content-encoding']
        
        if encoding != ContentEncoding.IDENTITY
            # Remove encoding, length headers
            delete headers['content-encoding']
            delete headers['content-length']
