| 31 | virtual bool supportPut(void) {return true;} |
| 32 | |
| 33 | virtual bool handleRequest(const HTTPRequest& request, HTTPReply& reply) { |
| 34 | if (DO_BASIC_AUTH) { |
| 35 | if (!request.authType.size() || !request.authCredentials.size()) { |
| 36 | reply.returnCode = HTTPReply::e401Unauthorized; |
| 37 | reply.authType = "Basic"; |
| 38 | reply.authRealm = "BZFS_Test_Access"; |
| 39 | reply.docType = HTTPReply::eHTML; |
| 40 | reply.body = "Authentication Required"; |
| 41 | return true; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | reply.returnCode = HTTPReply::e200OK; |
| 46 | reply.docType = HTTPReply::eHTML; |
| 47 | if (request.request == ePut) { |
| 48 | // read in what we got |
| 49 | // send them back what we got |
| 50 | reply.docType = HTTPReply::eOctetStream; |
| 51 | reply.body = request.body; |
| 52 | } |
| 53 | else { |
| 54 | reply.body = format("<html><head></head><body>\n"); |
| 55 | |
| 56 | reply.body += format("Your sessionID is %d<br>\n", request.sessionID); |
| 57 | reply.body += "<a href=\"" + request.baseURL + "link1\">Link1</a><br>"; |
| 58 | reply.body += "<a href=\"" + request.baseURL + "link2\">Link2</a>"; |
| 59 | |
| 60 | if (request.authType.size() && request.authCredentials.size()) { |
| 61 | reply.body += "<br>You authenticated, using the type: " + request.authType + "<br>"; |
| 62 | reply.body += "<br>Your credentials are: " + request.authCredentials + "<br>"; |
| 63 | |
| 64 | if (request.username.size() && request.password.size()) { |
| 65 | reply.body += "<br>Your username is: " + request.username + "<br>"; |
| 66 | reply.body += "<br>Your password is: " + request.password + "<br>"; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | reply.body += "</body></html>"; |
| 71 | } |
| 72 | return true; |
| 73 | } |
| 74 | }; |
| 75 | |
| 76 | HTTPTest* server = NULL; |