| 32 | { |
| 33 | |
| 34 | void KeeperJemallocWebUIHandler::handleRequest( |
| 35 | HTTPServerRequest & request, HTTPServerResponse & response, const ProfileEvents::Event &) |
| 36 | { |
| 37 | std::string html(reinterpret_cast<const char *>(resource_jemalloc_html), std::size(resource_jemalloc_html)); |
| 38 | |
| 39 | constexpr std::string_view head_close = "<head>"; |
| 40 | auto pos = html.find(head_close); |
| 41 | if (pos != std::string::npos) |
| 42 | html.insert(pos + head_close.size(), "<script>window.JEMALLOC_CONFIG={mode:'keeper'}</script>"); |
| 43 | |
| 44 | response.setContentType("text/html; charset=UTF-8"); |
| 45 | if (request.getVersion() == HTTPServerRequest::HTTP_1_1) |
| 46 | response.setChunkedTransferEncoding(true); |
| 47 | |
| 48 | setResponseDefaultHeaders(response); |
| 49 | response.setStatusAndReason(Poco::Net::HTTPResponse::HTTP_OK); |
| 50 | auto wb = WriteBufferFromHTTPServerResponse(response, request.getMethod() == HTTPRequest::HTTP_HEAD); |
| 51 | wb.write(html.data(), html.size()); |
| 52 | wb.finalize(); |
| 53 | } |
| 54 | |
| 55 | void KeeperJemallocRedirectHandler::handleRequest( |
| 56 | HTTPServerRequest &, HTTPServerResponse & response, const ProfileEvents::Event &) |
nothing calls this directly
no test coverage detected