     @configuration.findPathForHost host, (path) =>
       if app = @applicationForConfig path
         app.proxyRequest reqBuf, res
-        reqBuf.flush()
       else
         @respondWithError res, "unknown host #{req.headers.host}"
+      reqBuf.flush()
 
   respondWithError: (res, err) ->
     res.writeHead 500, "Content-Type": "text/html"

  close: ->
    @server.close()

  applicationForConfig: (config) ->
    @applications[config] ?= nack.createPool config, size: 3, idle: idle

  onRequest: (req, res) ->
    reqBuf = new BufferedReadStream req

http = require 'http'

{createPool}         = require 'nack/pool'
{logStream}          = require 'nack/logger'
{BufferedReadStream} = require 'nack/buffered'

idle = 1000 * 60 * 15
