       req.end data
       req.on 'response', (res) -> cb res.statusCode != 200, res
 
+  getJSONGzipped: (filename, headers, cb) ->
+    if arguments.length == 2
+      cb = headers
+      headers = {}
+
+    @getGzip parseJSON: true, filename, headers, cb
+
   getGzip: (opts, filename, headers, cb) ->
+
     if arguments.length == 2
       cb = headers
       headers = {}

      opts = parseJSON: false

    filename = filename.toString()

    headers['Accept-Encoding:'] = 'gzip'

    @getFile filename, headers, (err, res) ->
      return cb err if err
      buffer = ''
      gunzip = zlib.createGunzip()
      res.pipe gunzip

      gunzip.on 'data', (data) -> buffer += data.toString 'utf8'

      gunzip.on 'end', ->
        result = if opts.parseJSON then JSON.parse buffer else buffer.toString()
        cb null, result

      gunzip.on 'error', (err) -> cb err

  getJSONGzipped: (filename, headers, cb) ->
    if arguments.length == 2
      cb = headers
      headers = {}

    @getGzip parseJSON: true, filename, headers, cb

  getJSON: (filename, headers, cb) ->
    if arguments.length == 2

zlib  = require 'zlib'
async = require 'async'
knox  = require 'knox'

registerReqListeners = (req, fn) ->
  req.on 'response', (res) -> fn(null, res)
  req.on('error', fn)

module.exports = class knoxSteroids extends knox

