Permalink
Browse files

removed statSync for sync with callback

  • Loading branch information...
1 parent fd783b5 commit 77d097932587b2c73169d87e893577db6ab2fb7d @phated phated committed Jan 26, 2012
Showing with 14 additions and 13 deletions.
  1. +14 −13 lib/http.coffee
View
@@ -47,21 +47,22 @@ http.serveRequest = (req, res) ->
res.writeHead 404
return res.end()
- if fs.statSync(filename).isDirectory()
- filename += '/' + config.index
- path.exists filename, (exists) ->
- unless exists
- res.writeHead 404
+ fs.stat filename, (err, stat) ->
+ if stat.isDirectory()
+ filename += '/' + config.index
+ path.exists filename, (exists) ->
+ unless exists
+ res.writeHead 404
+ return res.end()
+
+ fs.readFile path.normalize(filename), 'binary', (err, file) ->
+ if err
+ res.writeHead 500
return res.end()
- fs.readFile path.normalize(filename), 'binary', (err, file) ->
- if err
- res.writeHead 500
- return res.end()
-
- res.writeHead 200, 'Content-Type': mime.lookup(filename)
- res.write file, 'binary'
- res.end()
+ res.writeHead 200, 'Content-Type': mime.lookup(filename)
+ res.write file, 'binary'
+ res.end()
http.processRequest = (req, res, cb) ->
userIP = req.connection.remoteAddress

0 comments on commit 77d0979

Please sign in to comment.