| 69 | } |
| 70 | |
| 71 | bool BZFSHTTP::handleRequest(const HTTPRequest& request, HTTPReply& reply) { |
| 72 | if (serviceMimeResources && resourceRootPath.size() && mimeTypes.size()) { |
| 73 | // parse out the resource and see if we know what it is |
| 74 | std::string ext; |
| 75 | tolower(getFileExtension(request.resource), ext); |
| 76 | |
| 77 | if (ext.size()) { |
| 78 | if (mimeTypes.find(ext) != mimeTypes.end()) { |
| 79 | // it's one we do, try and find it |
| 80 | std::string filepath = concatPaths(resourceRootPath.c_str(), request.resource.c_str()); |
| 81 | |
| 82 | FILE* fp = fopen(filepath.c_str(), "rb"); |
| 83 | if (fp) { |
| 84 | char buffer[1024]; |
| 85 | bool done = false; |
| 86 | |
| 87 | while (!done) { |
| 88 | size_t read = fread(buffer, 1, 1024, fp); |
| 89 | if (read) { |
| 90 | reply.addBody(buffer, read); |
| 91 | } |
| 92 | |
| 93 | if (read != 1024) { |
| 94 | done = true; |
| 95 | } |
| 96 | } |
| 97 | fclose(fp); |
| 98 | |
| 99 | reply.docType = HTTPReply::eOther; |
| 100 | reply.otherMimeType = mimeTypes[ext]; |
| 101 | reply.returnCode = HTTPReply::e200OK; |
| 102 | return true; |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | return generatePage(request, reply); |
| 109 | } |
| 110 | |
| 111 | bool HTTPRequest::getParam(const char* param, std::string& val) const { |
| 112 | val = ""; |
nothing calls this directly
no test coverage detected