Import civetweb ans jsoncpp

This commit is contained in:
2016-02-27 00:07:26 +01:00
parent 5ed9eb9715
commit 3bc376da33
1153 changed files with 554633 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
#!/bin/sh
echo "Content-Type: text/plain; charset=utf-8"
echo "Connection: close"
echo "Cache-Control: no-cache"
echo ""
echo "{}"

View File

@@ -0,0 +1,73 @@
#!/usr/bin/lua5.1
-- Every CGI script that returns any valid JSON object will work in the test.
-- In case you do not have not yet used CGI, you may want to use this script which is written in Lua.
-- You may download an interpreter from http://luabinaries.sourceforge.net/download.html, extract it
-- to some folder in your search path (the path of the webserver or /usr/bin on Linux), and add the
-- following lines to your .conf file.
-- cgi_interpreter c:\somewhere\lua5.1.exe
-- enable_keep_alive yes
resp = "{";
method = os.getenv("REQUEST_METHOD")
uri = os.getenv("REQUEST_URI");
query = os.getenv("QUERY_STRING");
datalen = os.getenv("CONTENT_LENGTH");
if method then
resp = resp .. '"method" : "' .. method .. '", ';
end
if uri then
resp = resp .. '"uri" : "' .. uri .. '", ';
end
if query then
resp = resp .. '"query" : "' .. query .. '", ';
end
if datalen then
resp = resp .. '"datalen" : "' .. datalen .. '", ';
end
resp = resp .. '"time" : "' .. os.date() .. '" ';
resp = resp .. "}";
print "Status: 200 OK"
print "Connection: close"
--print "Connection: keep-alive"
print "Content-Type: text/html; charset=utf-8"
print "Cache-Control: no-cache"
--print ("Content-Length: " .. resp:len())
print ""
print (resp)
doLogging = false
if (doLogging) then
-- Store the POST data to a file
if (method == "POST") then
myFile = io.open("data" .. query:sub(4) .. ".txt", "wb");
myFile:write(resp)
myFile:write("\r\n\r\n")
if datalen then
datalen = tonumber(datalen)
myFile:write("<<< " .. datalen .. " bytes of data >>>\r\n")
data = io.stdin:read(datalen)
myFile:write(data)
myFile:write("\r\n<<< end >>>\r\n")
else
myFile:write("<<< no data >>>\r\n")
end
myFile:close()
end
end

View File

@@ -0,0 +1,9 @@
<?
-- This *.lp file simply runs the *.lua file in the same directory.
n = string.match(mg.request_info.uri, "^(.*)%.lp$")
if mg.system:find("Windows") then
n = string.gsub(n, [[/]], [[\]])
end
n = mg.document_root .. n .. ".lua"
dofile(n)
?>

View File

@@ -0,0 +1,35 @@
resp = "{";
method = mg.request_info.request_method
uri = mg.request_info.uri
query = mg.request_info.query_string
datalen = nil -- TODO: "CONTENT_LENGTH" !
if method then
resp = resp .. '"method" : "' .. method .. '", ';
end
if uri then
resp = resp .. '"uri" : "' .. uri .. '", ';
end
if query then
resp = resp .. '"query" : "' .. query .. '", ';
end
if datalen then
resp = resp .. '"datalen" : "' .. datalen .. '", ';
end
resp = resp .. '"time" : "' .. os.date() .. '" ';
resp = resp .. "}";
mg.write("HTTP/1.1 200 OK\r\n")
mg.write("Connection: close\r\n")
mg.write("Content-Type: text/html\r\n")
mg.write("Cache-Control: no-cache\r\n")
--mg.write("Content-Length: " .. resp:len() .. "\n")
mg.write("\r\n")
mg.write(resp)

4
3P/civetweb/test/ajax/jquery.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,167 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Test</title>
<script type='text/javascript' language="javascript" src='jquery.js'></script>
<script type='text/javascript' language="javascript">
<!--
function mbox() {
alert('Javascript OK');
}
var totalCount = 10;
var pendingCount = 0;
var errorCount = 0;
var pushCount = 0;
var allErrorCount = 0;
var autoTest = false;
var testType = "cgi";
function NextTestType() {
if (testType == "cgi") testType = "lp";
else if (testType == "lp") testType = "lua";
else testType = "cgi";
}
function runTest(method, isAsync) {
++pushCount;
document.getElementById('start').innerHTML = 'Test: ' + pushCount;
document.getElementById('resTotal').innerHTML = 'running';
for (var i = 1; i <= totalCount; ++i) {
document.getElementById('res'+i).innerHTML = "ready";
}
errorCount = 0;
pendingCount = totalCount;
for (var i = 1; i <= totalCount; ++i) {
fetch(i, method, isAsync);
}
}
function runAutoTest() {
if (autoTest) {
runTest("POST", true)
setTimeout("runAutoTest()", 250)
}
}
function fetch(id, method, isAsync) {
document.getElementById('res'+id).innerHTML = "pending";
$.ajax({
async: isAsync,
url: 'echo.' + testType + '?id=' + id,
type: method,
timeout: 2000,
data: { 'id' : id ,
'longText1' : "adfsdfasdklkjlgasfdfjkhq345sdafbmkanq3trsdghkjqw4etrjlkabsdfkabvauiregtlkjasdbvabl4btrjawebbfjsdhbjk342r5bjksdbfkljbhasdfbhj234qjhasdg76k11234jhv900adfasddsfmzasdfhjgajsvhgkjhasdf77aefcae4fkjzasdfgukeaf7dkkegasdfigjcvxgui",
'longText2' : "bsdfsdfasdklkjlgasdfjkhq345sdafbmkanq3trsdghkjqw4etrjlkabsdfkabvauiregtlkjasdbvabl4btrjawebbfjsdhbjk342r5bjksdbfkljbhasdfbhj234qjhasdg76k11234jhv900adfasddsfmzasdfhjgajsvhgkjhasdf77aefcae4fkjzasdfgukeaf7dkkegasdfigjcvxgui",
'longText3' : "sdfsadagsdklkjlgasdfjkhq345sdafbmkanq3trsdghkjqw4etrjlkabsdfkabvauiregtlkjasdbvabl4btrjawebbfjsdhbjk342r5bjksdbfkljbhasdfbhj234qjhasdg76k11234jhv900adfasddsfmzasdfhjgajsvhgkjhasdf77aefcae4fkjzasdfgukeaf7dkkegasdfigjcvxgui",
'longText4' : "q34sdfas3fhbkjlgasdfjkhq345sdafbmkanq3trsdghkjqw4etrjlkabsdfkabvauiregtlkjasdbvabl4btrjawebbfjsdhbjk342r5bjksdbfkljbhasdfbhj234qjhasdg76k11234jhv900adfasddsfmzasdfhjgajsvhgkjhasdf77aefcae4fkjzasdfgukeaf7dkkegasdfigjcvxgui",
'longText5' : "askj2kjcvxychklgasdfjkhq345sdafbmkanq3trsdghkjqw4etrjlkabsdfkabvauiregtlkjasdbvabl4btrjawebbfjsdhbjk342r5bjksdbfkljbhasdfbhj234qjhasdg76k11234jhv900adfasddsfmzasdfhjgajsvhgkjhasdf77aefcae4fkjzasdfgukeaf7dkkegasdfigjcvxgui",
'longText6' : "asdfjklhlkjhv8öajsdfjkhq345sdafbmkanq3trsdghkjqw4etrjlkabsdfkabvauiregtlkjasdbvabl4btrjawebbfjsdhbjk342r5bjksdbfkljbhasdfbhj234qjhasdg76k11234jhv900adfasddsfmzasdfhjgajsvhgkjhasdf77aefcae4fkjzasdfgukeaf7dkkegasdfigjcvxgui",
'async' : isAsync
},
dataType: 'json',
succes: function(data) {
},
error: function() {
++errorCount;
},
complete: function(jqXHR, textStatus) {
--pendingCount;
document.getElementById('res'+id).innerHTML = textStatus;
console.log('id: ' + id + ' (' + pendingCount + '/' + totalCount + '), status: ' + textStatus);
if (pendingCount == 0) {
document.getElementById('resTotal').innerHTML = 'done';
console.log('complete, error count: ' + errorCount);
allErrorCount = allErrorCount + errorCount;
document.getElementById('resSAll').innerHTML = 'total errors: ' + allErrorCount + "/" + (pushCount*totalCount);
}
}
});
}
//-->
</script>
</head>
<body>
<p>
<div id="start">Test not started.</div>
</p>
<p>
<table>
<tr>
<td>
<input id="testButton1" type="button" onclick="javascript:runTest('GET', false)" value="sync GET"></input>
</td>
<td>
<input id="testButton2" type="button" onclick="javascript:runTest('POST', false)" value="sync POST"></input>
</td>
</tr>
<tr>
<td>
<input id="testButton3" type="button" onclick="javascript:runTest('GET', true)" value="async GET"></input>
</td>
<td>
<input id="testButton4" type="button" onclick="javascript:runTest('POST', true)" value="async POST"></input>
</td>
</tr>
<tr>
<td>
<input id="testButton5" type="button" onclick="autoTest=!autoTest; javascript:runAutoTest()" value="automatic test"></input>
</td>
<td>
<input id="testButton6" type="button" onclick="NextTestType(); this.value=testType" value='cgi'></input>
</td>
</tr>
<tr>
<td>
<input id="testButtonReset" type="button" onclick="autoTest=false; javascript:location.reload(true)" value="reset"></input>
</td>
<td>
</td>
</tr>
<tr>
<td>
<input id="testButtonBox" type="button" onclick="javascript:mbox()" value="MsgBox"></input>
</td>
<td>
</td>
</tr>
</table>
</p>
<p>
<table border="1">
<tr><th>Test</th><th>Result</th></tr>
<tr><td>1</td><td><div id="res1">not started</div></td></tr>
<tr><td>2</td><td><div id="res2">not started</div></td></tr>
<tr><td>3</td><td><div id="res3">not started</div></td></tr>
<tr><td>4</td><td><div id="res4">not started</div></td></tr>
<tr><td>5</td><td><div id="res5">not started</div></td></tr>
<tr><td>6</td><td><div id="res6">not started</div></td></tr>
<tr><td>7</td><td><div id="res7">not started</div></td></tr>
<tr><td>8</td><td><div id="res8">not started</div></td></tr>
<tr><td>9</td><td><div id="res9">not started</div></td></tr>
<tr><td>10</td><td><div id="res10">not started</div></td></tr>
</table>
<div id="resTotal">Push [Test] to start.</div>
<div id="resSAll"></div>
</p>
</body>
</html>