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