first commit

This commit is contained in:
s.golasch
2023-08-01 13:49:46 +02:00
commit 1fc239fd54
20238 changed files with 3112246 additions and 0 deletions

34
build/node_modules/node-rest-client/test/message.json generated vendored Normal file
View File

@@ -0,0 +1,34 @@
{"catalog":{
"books":[{
"id":"bk101",
"author":"Gambardella, Matthew",
"title":"XML Developer's Guide",
"genre":"Computer",
"price":44.95,
"publish_date":"2000-10-10",
"description":"An in-depth look at creating applications with XML."
},
{
"id":"bk102",
"author":"Gambardella, Matthew",
"title":"JAVA Developer's Guide",
"genre":"Computer",
"price":188.95,
"publish_date":"2000-10-10",
"description":"An in-depth look at creating applications with JAVA."
},
{
"id":"bk103",
"author":"Gambardella, Matthew",
"title":"JSON Developer's Guide",
"genre":"Computer",
"price":422.95,
"publish_date":"2000-10-10",
"description":"An in-depth look at creating applications with JSON."
}
]
}
}

43
build/node_modules/node-rest-client/test/message.xml generated vendored Normal file
View File

@@ -0,0 +1,43 @@
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.</description>
</book>
<book id="bk103">
<author>Corets, Eva</author>
<title>Maeve Ascendant</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-11-17</publish_date>
<description>After the collapse of a nanotechnology
society in England, the young survivors lay the
foundation for a new society.</description>
</book>
<book id="bk104">
<author>Corets, Eva</author>
<title>Oberon's Legacy</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2001-03-10</publish_date>
<description>In post-apocalypse England, the mysterious
agent known only as Oberon helps to create a new life
for the inhabitants of London. Sequel to Maeve
Ascendant.</description>
</book>
</catalog>

32
build/node_modules/node-rest-client/test/specs.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
var jasmine = require('jasmine-node');
var sys = require('sys');
for(var key in jasmine) {
global[key] = jasmine[key];
}
var isVerbose = true;
var showColors = true;
process.argv.forEach(function(arg){
switch(arg) {
case '--color': showColors = true; break;
case '--noColor': showColors = false; break;
case '--verbose': isVerbose = true; break;
}
});
var options = {"specFolder":__dirname.concat("\\spec"),
"onComplete": function(runner, log){
if (runner.results().failedCount == 0) {
process.exit(0);
}
else {
process.exit(1);
}
},
"isVerbose": isVerbose,
"showColors": showColors};
jasmine.executeSpecsInFolder(options);

85
build/node_modules/node-rest-client/test/test-proxy.js generated vendored Normal file
View File

@@ -0,0 +1,85 @@
var http = require('http');
var sys = require('sys');
var fs = require('fs');
var blacklist = [];
var iplist = [];
fs.watchFile('./blacklist', function(c,p) { update_blacklist(); });
fs.watchFile('./iplist', function(c,p) { update_iplist(); });
function update_blacklist() {
sys.log("Updating blacklist.");
blacklist = fs.readFileSync('./blacklist').split('\n')
.filter(function(rx) { return rx.length })
.map(function(rx) { return RegExp(rx) });
}
function update_iplist() {
sys.log("Updating iplist.");
iplist = fs.readFileSync('./iplist').split('\n')
.filter(function(rx) { return rx.length });
}
function ip_allowed(ip) {
for (i in iplist) {
if (iplist[i] == ip) {
return true;
}
}
return false;
}
function host_allowed(host) {
for (i in blacklist) {
if (blacklist[i].test(host)) {
return false;
}
}
return true;
}
function deny(response, msg) {
response.writeHead(401);
response.write(msg);
response.end();
}
http.createServer(function(request, response) {
var ip = request.connection.remoteAddress;
if (!ip_allowed(ip)) {
msg = "IP " + ip + " is not allowed to use this proxy";
deny(response, msg);
sys.log(msg);
return;
}
if (!host_allowed(request.url)) {
msg = "Host " + request.url + " has been denied by proxy configuration";
deny(response, msg);
sys.log(msg);
return;
}
sys.log(ip + ": " + request.method + " " + request.url);
var proxy = http.createClient(80, request.headers['host']);
var proxy_request = proxy.request(request.method, request.url, request.headers);
proxy_request.addListener('response', function(proxy_response) {
proxy_response.addListener('data', function(chunk) {
response.write(chunk, 'binary');
});
proxy_response.addListener('end', function() {
response.end();
});
response.writeHead(proxy_response.statusCode, proxy_response.headers);
});
request.addListener('data', function(chunk) {
proxy_request.write(chunk, 'binary');
});
request.addListener('end', function() {
proxy_request.end();
});
}).listen(8080);
update_blacklist();
update_iplist();

View File

@@ -0,0 +1,81 @@
var http = require('http'),
fs = require('fs');
// Create an HTTP server
var httpSrv = http.createServer(function (req, res) {
console.log("req.url", req.url);
RouteManager.findRoute(req,res);
});
var RouteManager ={
"findRoute":function(req,res){
var handler = this.routes[req.url];
if (!handler) throw "cannot find route " + req.url;
handler.call(this,req,res);
},
"routes":{
"/json":function(req,res){
//this.sleep(5000);
var message = fs.readFileSync('./message.json','utf8');
res.writeHead(200, {'Content-Type': 'application/json'});
res.write(message.toString());
res.end();
},
"/xml":function(req,res){
var message = fs.readFileSync('./message.xml','utf8');
res.writeHead(200, {'Content-Type': 'application/xml'});
res.write(message.toString());
res.end();
},
"/120/json?arg1=hello&arg2=world":function(req,res){
if (!req.headers["test-header"]) throw "no test-header found!!";
res.setHeader("test-response-header",req.headers["test-header"]);
this.routes["/json"](req,res);
},
"/json?post":function(req,res){
req.on('data',function(data){
console.log("[SERVER] data = ", data);
res.writeHead(200, {'Content-Type': 'application/json'});
//res.writeHead(200, {'Content-Type': 'text/plain'});
res.write(data.toString());
res.end();
});
},
"/json/empty":function(req,res){
res.writeHead(204, {'Content-Type': 'application/json'});
res.end();
},
"/xml/empty":function(req,res){
res.writeHead(204, {'Content-Type': 'application/xml'});
res.end();
},
"/json/contenttypewithspace":function(req,res){
var message = fs.readFileSync('./message.json','utf8');
res.writeHead(200, {'Content-Type': 'application/json; charset=utf-8'});
res.write(message.toString());
res.end();
}
},
"sleep":function(ms){
var stop = new Date().getTime();
while(new Date().getTime() < stop + ms) {
;
}
}
};
httpSrv.on('error',function(err){
console.error('error starting http test server',err);
});
httpSrv.listen(4444);
console.log('http server Listening on port ' + 4444);