Some more HTTP POST evaluation. Still broken! (0.39.10)
This commit is contained in:
parent
e240768c26
commit
5222f79434
5 changed files with 176 additions and 26 deletions
|
|
@ -16,21 +16,39 @@
|
|||
cgi = CGI()
|
||||
cgi.content_type("text/html; charset=utf-8")
|
||||
pmap = cgi.params()
|
||||
html = "<html><body><h1>POST fields</h1><ul>"
|
||||
for k in keys(pmap)
|
||||
// Build HTML with a form at the top to submit POST data back to this script
|
||||
html = "<html><body>"
|
||||
html = html + "<h1>Submit data</h1>"
|
||||
html = html + "<form method=\"POST\" action=\"\">"
|
||||
html = html + "<label>A: <input type=\"text\" name=\"a\" value=\"1\"></label><br>"
|
||||
html = html + "<label>B: <input type=\"text\" name=\"b\" value=\"2\"></label><br>"
|
||||
html = html + "<label>C: <input type=\"text\" name=\"c\" value=\"3\"></label><br>"
|
||||
html = html + "<button type=\"submit\">Submit</button>"
|
||||
html = html + "</form>"
|
||||
html = html + "<h1>POST fields</h1><ul>"
|
||||
|
||||
// Always show fields a, b, and c (print names even if no value was submitted)
|
||||
names = ["a", "b", "c"]
|
||||
i_name = 0
|
||||
n_names = len(names)
|
||||
while (i_name < n_names)
|
||||
k = names[i_name]
|
||||
vals = cgi.param_all(k)
|
||||
i = 0; n = len(vals); joined = ""
|
||||
i = 0
|
||||
n = len(vals)
|
||||
joined = ""
|
||||
while (i < n)
|
||||
if (i > 0) joined = joined + ", "
|
||||
joined = joined + cgi.escape_html(vals[i])
|
||||
i = i + 1
|
||||
html = html + "<li><b>" + cgi.escape_html(k) + "</b>: " + joined + "</li>"
|
||||
i_name = i_name + 1
|
||||
html = html + "</ul></body></html>"
|
||||
cgi.send(html)
|
||||
|
||||
/* Expected output (POST with body: "a=1&b=two&b=2"):
|
||||
/* Possible output (POST with body: "a=1&b=2&c=3"):
|
||||
Status: 200 OK
|
||||
Content-Type: text/html; charset=utf-8
|
||||
|
||||
<html><body><h1>POST fields</h1><ul><li><b>a</b>: 1</li><li><b>b</b>: two, 2</li></ul></body></html>
|
||||
<html><body><h1>POST fields</h1><ul><li><b>a</b>: 1</li><li><b>b</b>: b, 2</li><li><b>c</b>: 3</li></ul></body></html>
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue