|
1 function handleRequest(request, response) |
|
2 { |
|
3 var auth = ""; |
|
4 try { |
|
5 auth = request.getHeader("Authorization"); |
|
6 } catch(e) {} |
|
7 |
|
8 if (auth == "Basic aHR0cHVzZXI6aHR0cHBhc3M=") { |
|
9 response.setStatusLine("1.1", 200, "OK"); |
|
10 response.write("<html><head><title>http auth success</title></head><html>"); |
|
11 } else { |
|
12 response.setStatusLine("1.1", 401, "Http authentication required"); |
|
13 response.setHeader("WWW-Authenticate", "Basic realm=\"http_realm\""); |
|
14 response.write("<html><head><title>http auth failed</title></head><html>"); |
|
15 } |
|
16 } |