Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

removed statSync for sync with callback

  • Loading branch information...
commit 77d097932587b2c73169d87e893577db6ab2fb7d 1 parent fd783b5
Blaine Bublitz authored January 25, 2012

Showing 1 changed file with 14 additions and 13 deletions. Show diff stats Hide diff stats

  1. 27  lib/http.coffee
27  lib/http.coffee
@@ -47,21 +47,22 @@ http.serveRequest = (req, res) ->
47 47
         res.writeHead 404
48 48
         return res.end()
49 49
 
50  
-      if fs.statSync(filename).isDirectory()
51  
-        filename += '/' + config.index
52  
-        path.exists filename, (exists) ->
53  
-          unless exists
54  
-            res.writeHead 404
  50
+      fs.stat filename, (err, stat) ->
  51
+        if stat.isDirectory()
  52
+          filename += '/' + config.index
  53
+          path.exists filename, (exists) ->
  54
+            unless exists
  55
+              res.writeHead 404
  56
+              return res.end()
  57
+
  58
+        fs.readFile path.normalize(filename), 'binary', (err, file) ->
  59
+          if err
  60
+            res.writeHead 500
55 61
             return res.end()
56 62
 
57  
-      fs.readFile path.normalize(filename), 'binary', (err, file) ->
58  
-        if err
59  
-          res.writeHead 500
60  
-          return res.end()
61  
-
62  
-        res.writeHead 200, 'Content-Type': mime.lookup(filename)
63  
-        res.write file, 'binary'
64  
-        res.end()
  63
+          res.writeHead 200, 'Content-Type': mime.lookup(filename)
  64
+          res.write file, 'binary'
  65
+          res.end()
65 66
 
66 67
 http.processRequest = (req, res, cb) ->
67 68
   userIP = req.connection.remoteAddress

0 notes on commit 77d0979

Please sign in to comment.
Something went wrong with that request. Please try again.