module.exports = function sendFile(name, absolute){
    var fs = require('fs')
       ,api  = require('../api.js')
    return function sendFile(req, res){
    var fstream = fs.createReadStream((absolute ? '' : __dirname + '/../../') + name)
        fstream.on('open', function(fd){
            try{
                res.writeHead(200,{
'Content-Type': ~name.indexOf('css') ? 'text/css' : 'application/javascript',
'Content-Length': fs.fstatSync(fd).size
                })
                fstream.pipe(res)
            } catch(ex){
                res.json('')
                api._err(api.ipt(ex))
            }
        })
        fstream.on('error', function(err){
            api._err(api.ipt(err))
            res.statusCode = 404
            res.end()
        })
    }
}

@@ -42,28 +42,24 @@
 absolute)%7B%0D%0A
-    
 var fs = req
@@ -70,20 +70,16 @@
 ('fs')%0D%0A
-    
    ,api 
@@ -261,346 +261,874 @@
 en',
- function(fd)%7B%0D%0A            try%7B%0D%0A                res.writeHead(200,%7B%0D%0A'Content-Type': ~name.indexOf('css') ? 'text/css' : 'application/javascript',%0D%0A'Content-Length': fs.fstatSync(fd).size%0D%0A                %7D)%0D%0A                fstream.pipe(res)%0D%0A            %7D catch(ex)%7B%0D%0A                res.json('')%0D%0A                api._err(api.ipt(ex)
+%0D%0A            function on_fstream_open(fd)%7B%0D%0A                fs.fstat(fd,%0D%0A                    function on_fstat(err, stat)%7B%0D%0A                        if(err)%7B%0D%0A                            res.statusCode = 500%0D%0A                            err = api.ipt(err)%0D%0A                            api._err(err)%0D%0A                            res.txt(err)%0D%0A                            return%0D%0A                        %7D%0D%0A                        res.setHeader('Content-Length', stat.size)%0D%0A                        res.setHeader('Content-Type',(%0D%0A                           ~name.indexOf('css') ? res.ContentTypes.TextCSS :%0D%0A                           ~name.indexOf('.js') ? res.ContentTypes.AppJS :%0D%0A                            res.ContentTypes.TextPlain)%5B'Content-Type'%5D%0D%0A                        )%0D%0A                        fstream.pipe(res)%0D%0A                    %7D%0D%0A                
 )%0D%0A 
@@ -1145,25 +1145,24 @@
  %7D%0D%0A        
-%7D
 )%0D%0A        f
@@ -1183,46 +1183,115 @@
 or',
- function(err)%7B%0D%0A            api._err(
+%0D%0A            function on_fstream_error(err)%7B%0D%0A                res.statusCode = 500%0D%0A                err = 
 api.
@@ -1298,17 +1298,16 @@
 ipt(err)
-)
 %0D%0A      
@@ -1316,30 +1316,31 @@
     
+  
-res.statusCode = 404%0D%0A
+  api._err(err)%0D%0A    
     
@@ -1355,12 +1355,15 @@
 res.
-end(
+txt(err
 )%0D%0A 
@@ -1369,17 +1369,31 @@
         
+ 
-%7D
+   %7D%0D%0A        
 )%0D%0A    %7D

rework for async and consisyent header setting