                 @converters =
                         mp3: new Mp3Converter()
                         ogg: new VorbisConverter()
+                @_ongoingConversions = {}
 
-        _conversionDone: (err, cacheInstance, tempname, response) =>
+        _redirectToCachefile: (cacheInstance, response) =>
+
+        _createResponse: (err, cacheInstance, tempname, callback) =>
                 if err
                         fs.exists tempname, (exists) =>
                                 if exists
                                         fs.unlink tempname
-                                response.send "Failed to convert.", 500
-                        return
+                                callback {data: ["Failed to convert.", 500], headers: {}}
+                                return
                 fs.stat tempname, (statErr, stats) =>
                         if statErr
-                                response.send "Failed to read resulting file name.", 500
+                                callback {data: ["Failed to read resulting file name.", 500], headers: {}}
                                 return
                         stream = fs.createReadStream tempname
                         stream.on "end", =>
                                 fs.unlink tempname
+
                         cacheInstance.createCache tempname, (err, location) ->
-                                response.set "location", location
-                                response.send "Go to #{location}", 302
+                                callback {data: ["Go to #{location}", 302], headers: {"location": location}}
+
+        _conversionDone: (err, cacheInstance, tempname) =>
+                @_createResponse err, cacheInstance, tempname, (responseParams) =>
+                        for response in @_ongoingConversions[cacheInstance.getKey()]
+                                for header, value of responseParams.headers
+                                        response.set(header, value)
+                                [content, code] = responseParams.data
+                                response.send content, code
+                        delete @_ongoingConversions[cacheInstance.getKey()]
 
         convert: (type, filename, response) =>
                 if type not of @converters

                                response.set "location", location
                                response.send "Go to #{location}", 302
                                return
                        fs.stat filename, (statErr, stats) =>
                                if statErr
                                        response.send "Failed to read original file name.", 500
                                        return

                                tempname = temp.path {suffix: ".#{suffix}"}
                                converter.convert filename, @bitrate, tempname, (err) =>
                                        @_conversionDone err, cacheInstance, tempname, response


exports.FileConverterView = class FileConverterView

        createCache: (convertedFilename, conversionParams, callback) =>
                filepath = @_getCacheName conversionParams
                input = fs.createReadStream convertedFilename
                input.on "error", (err) =>
                        console.log "Read stream error: #{err}"
                output = fs.createWriteStream filepath
                input.pipe output
                input.on "end", =>
