|
1 function handleRequest(request, response) |
|
2 { |
|
3 try { |
|
4 reallyHandleRequest(request, response); |
|
5 } catch (e) { |
|
6 response.setStatusLine("1.0", 200, "AlmostOK"); |
|
7 response.write("Error handling request: " + e); |
|
8 } |
|
9 } |
|
10 |
|
11 |
|
12 function reallyHandleRequest(request, response) { |
|
13 var match; |
|
14 var requestAuth = true; |
|
15 |
|
16 // XXX I bet this doesn't work for POST requests. |
|
17 var query = request.queryString; |
|
18 |
|
19 var user = null, pass = null; |
|
20 // user=xxx |
|
21 match = /user=([^&]*)/.exec(query); |
|
22 if (match) |
|
23 user = match[1]; |
|
24 |
|
25 // pass=xxx |
|
26 match = /pass=([^&]*)/.exec(query); |
|
27 if (match) |
|
28 pass = match[1]; |
|
29 |
|
30 response.setStatusLine("1.0", 200, "OK"); |
|
31 |
|
32 response.setHeader("Content-Type", "application/xhtml+xml", false); |
|
33 response.write("<html xmlns='http://www.w3.org/1999/xhtml'>"); |
|
34 response.write("<p>User: <span id='user'>" + user + "</span></p>\n"); |
|
35 response.write("<p>Pass: <span id='pass'>" + pass + "</span></p>\n"); |
|
36 response.write("</html>"); |
|
37 } |