-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestServer.js
76 lines (54 loc) · 1.72 KB
/
testServer.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
67
68
69
70
71
72
73
74
75
76
/*
function Response(request, response, httpStatusCode, header, data) {
this.request = request;
this.response = response;
this.httpStatusCode = httpStatusCode;
this.header = header;
this.data = data | "";
this.send = function() {
response.writeHead(httpStatusCode, header.getFields());
response.end(data, 'binary');
};
this.sendOnlyHeader = function() {
response.writeHead(httpStatusCode, header.getFields());
response.end();
};
}
function HTTPResponseHeader(contentType, contentLength) {
var httpResponseHeaderFields = {};
httpResponseHeaderFields['Server'] = SERVER_NAME;
httpResponseHeaderFields['Date'] = (new Date()).toGMTString();
httpResponseHeaderFields['Content-Type'] = contentType;
if(contentLength) {
httpResponseHeaderFields['Content-Length'] = contentLength;
}
this['Expires'] = '';
this.getFields = function() {
return httpResponseHeaderFields;
};
this.setLastModified = function(date) {
httpResponseHeaderFields['Last-Modified'] = date;
};
this.setContentType = function(contentLength) {
httpResponseHeaderFields['Content-Type'] = contentLength;
};
this.setContentLength = function(contentLength) {
httpResponseHeaderFields['Content-Length'] = contentLength;
};
this.setContentRange = function(contentRange) {
httpResponseHeaderFields['Content-Range'] = contentRange;
};
this.setAcceptRanges = function(value) {
httpResponseHeaderFields['Accept-Ranges'] = value;
};
this.setCacheControl = function(value) {
httpResponseHeaderFields['Cache-Control'] = value;
};
this.setExpires = function(value) {
httpResponseHeaderFields['Expires'] = value;
};
this.setEtag = function(value) {
httpResponseHeaderFields['Etag'] = value;
};
}
*/