Skip to content

Commit 09ec945

Browse files
save file
1 parent c8d9a01 commit 09ec945

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

blog/25-07-24/http-server/ex/http-server-simple-example.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,27 @@
4444
return;
4545
}
4646

47-
if(!fs.existsSync(abs)){
47+
48+
var err;
49+
try{
50+
51+
var stat = fs.statSync(abs);
52+
53+
}//try
54+
catch(err2){
55+
56+
err = err2;
57+
58+
}//catch
59+
if(err){
4860
notfound(req,res);
4961
return;
5062
}
63+
if(!stat.isFile()){
64+
notfound(req,res);
65+
return;
66+
}
67+
5168

5269

5370
var stream = fs.createReadStream(abs);

0 commit comments

Comments
 (0)