-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathtest.js
66 lines (50 loc) · 1.25 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var ifile = require('./index.js')
var zlib = require('zlib');
var path = require('path')
ifile.add([
//["/static2",__dirname+path.sep+"test"],
['/test',__dirname],
//["/static2/",__dirname+path.sep+"user",0],
//["static","user",[]],
//["static/sss/","user",['js','css']],
//["/static/ss/","user"+path.sep+"fsdf",['js']],
//["/static/saa","user"+path.sep+"fsdf"+path.sep,[]]
],function(req, res, isStatic){
//console.log(res)
//res.end('isStatic: '+isStatic);
res.statusCode = 404;
res.end('404')
})
var req= {
url:'/static2/static2/aaa.js',
method:'GET',
headers:{
//"if-none-match":"1370955406_34",
//"if-modified-since":"Thu, 13 Feb 2014 18:35:31 GMT",
"accept-encoding":"gzip,deflate,sdch"
}
}
var res = {
end:function(buf){
/*
zlib.gunzip(buf, function(err,buf2){
if(err) throw(err)
console.log(buf2.length);
console.log(buf2.toString())
})
*/
console.log(buf.length)
console.log(buf.toString())
},
setHeader:function(name,value){
console.log(name)
console.log(value)
}
}
ifile.route(req,res);
var http = require('http');
http.createServer(function (request, response) {
console.log(request.headers)
ifile.route(request,response);
}).listen(8124);
console.log('Server running at http://127.0.0.1:8124/');