-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtml_file_processing.js
More file actions
59 lines (53 loc) · 1.44 KB
/
html_file_processing.js
File metadata and controls
59 lines (53 loc) · 1.44 KB
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
<<<<<<< HEAD
=======
var fs = require('fs');
var path = require("path");
var responses = require('./responses.js')
var webp = require('./html_errors.js')
function parse_file(headers)
{
var lines;
var pat;
var i;
var j;
i = 0;
j = 0;
lines = headers.toString().split('\r\n');
pat = lines[0].toString().split(' ');
return (pat[1]);
}
function verify_send_file(pat, response, request, send_socket)
{
var resbody;
var code_status;
code_status = 0;
fs.exists(path.join(__dirname + pat), function(exists)
{
if (exists)
{
if (pat[pat.length - 1] == '/')
code_status = 403;
if (code_status.toString()[0] == '4' || code_status.toString()[0] == '5')
{
resbody = webp[code_status];
response = responses.create_res_err(pat, code_status);
send_socket(response, resbody);
return (0)
}
code_status = 200;
resbody = fs.readFileSync(path.join(__dirname + pat));
response = responses.create_res(pat, code_status);
send_socket(response, resbody);
}
else
{
code_status = 404;
resbody = webp[code_status];
response = responses.create_res_err(pat, code_status);
send_socket(response, resbody);
}
});
}
exports.parse_file = parse_file;
exports.verify_send_file = verify_send_file;
>>>>>>> cf0ca9116bc615096057d18c742d57d410254340