       this.failWithError(err)
 
   doFetch: (urlString) ->
-    http.get(url.parse(urlString), (imageResponse) =>
+    protocol = if (0 == urlString.indexOf('https')) then https else http
+    protocol.get(url.parse(urlString), (imageResponse) =>
       try
         if imageResponse.statusCode == 200
           this.processImage(imageResponse, urlString)

      'Content-Type': 'text/plain'
      'Cache-Control': 'no-cache'
    )
    @response.end(err.message)

module.exports = (options) ->
  (req, res, next) ->

      console.log("[ERR] error fetching image: #{err.message}")
      this.failWithError(err)

    ).on('close', =>
      console.log("[ERR] connection closed")
      this.fail(500, 'Connection closed')

    ).on('socket', (socket) =>
      socket.setTimeout(@ns.timeout) if @ns.timeout?
    )

