 				if isAccessible username, req.params[0], req.params[1]
 					debug "#{username} downloaded #{req.params[0]}/#{req.params[1].toLowerCase()}"
 					logDownload req.params[0], req.params[1]
-					res.download "#{config.packageFolder}/#{req.params[0]}/#{req.params[1].toLowerCase()}.tar", "#{req.params[0]}_v#{req.params[1]}.tar", (err) -> res.send 404, '404 Not Found' if err?
+					res.download "#{config.packageFolder}/#{req.params[0]}/#{req.params[1].toLowerCase()}.tar", "#{req.params[0]}_v#{req.params[1]}.tar", (err) -> res.status(404).send '404 Not Found' if err?
 				else
 					debug "#{username} tried to download #{req.params[0]}/#{req.params[1].toLowerCase()}"
 					askForCredentials req, res
 			else
-				res.send 404, '404 Not Found'
+				res.status(404).send '404 Not Found'
 		
 	checkAuth req, res, callback
 

askForCredentials = (req, res) ->
	res.type 'txt'
	res.setHeader 'WWW-Authenticate', 'Basic realm="Please provide proper username and password to access this package"'
	res.send 401, 'Please provide proper username and password to access this package'
	
app.all '/', (req, res) ->
	callback = (username) ->

		readPackages -> res.redirect 303, config.basePath ? "#{req.protocol}://#{req.header 'host'}/"

# throw 404 on any unknown route
app.all '*', (req, res) -> res.status(404).send '404 Not Found'

# Once the package list was successfully scanned once bind to the port
readPackages -> app.listen config.port, config.ip
