]> git.proxmox.com Git - ceph.git/blame - ceph/src/civetweb/test/ajax/echo.cgi.old
buildsys: switch source download to quincy
[ceph.git] / ceph / src / civetweb / test / ajax / echo.cgi.old
CommitLineData
7c673cae
FG
1#!/usr/bin/lua5.1\r
2\r
3-- Every CGI script that returns any valid JSON object will work in the test.\r
4-- In case you do not have not yet used CGI, you may want to use this script which is written in Lua.\r
5-- You may download an interpreter from http://luabinaries.sourceforge.net/download.html, extract it\r
6-- to some folder in your search path (the path of the webserver or /usr/bin on Linux), and add the\r
7-- following lines to your .conf file.\r
8-- cgi_interpreter c:\somewhere\lua5.1.exe\r
9-- enable_keep_alive yes\r
10\r
11resp = "{";\r
12\r
13method = os.getenv("REQUEST_METHOD")\r
14uri = os.getenv("REQUEST_URI");\r
15query = os.getenv("QUERY_STRING");\r
16datalen = os.getenv("CONTENT_LENGTH");\r
17\r
18if method then\r
19 resp = resp .. '"method" : "' .. method .. '", ';\r
20end\r
21if uri then\r
22 resp = resp .. '"uri" : "' .. uri .. '", ';\r
23end\r
24if query then\r
25 resp = resp .. '"query" : "' .. query .. '", ';\r
26end\r
27if datalen then\r
28 resp = resp .. '"datalen" : "' .. datalen .. '", ';\r
29end\r
30\r
31resp = resp .. '"time" : "' .. os.date() .. '" ';\r
32\r
33resp = resp .. "}";\r
34\r
35\r
36\r
37\r
38print "Status: 200 OK"\r
39print "Connection: close"\r
40--print "Connection: keep-alive"\r
41print "Content-Type: text/html; charset=utf-8"\r
42print "Cache-Control: no-cache"\r
43--print ("Content-Length: " .. resp:len())\r
44print ""\r
45\r
46print (resp)\r
47\r
48\r
49doLogging = false\r
50\r
51if (doLogging) then\r
52 -- Store the POST data to a file\r
53 if (method == "POST") then\r
54 myFile = io.open("data" .. query:sub(4) .. ".txt", "wb");\r
55 myFile:write(resp)\r
56 myFile:write("\r\n\r\n") \r
57 if datalen then\r
58 datalen = tonumber(datalen)\r
59 myFile:write("<<< " .. datalen .. " bytes of data >>>\r\n")\r
60 \r
61 data = io.stdin:read(datalen)\r
62 myFile:write(data)\r
63 \r
64 myFile:write("\r\n<<< end >>>\r\n")\r
65 else\r
66 myFile:write("<<< no data >>>\r\n")\r
67 end \r
68 myFile:close()\r
69 end\r
70end\r
71\r
72\r
73\r