#include "IdentifierQuoteHandler.h" #if USE_ODBC #include #include #include #include #include #include #include #include #include #include #include "getIdentifierQuote.h" #include "validateODBCConnectionString.h" #include namespace DB { void IdentifierQuoteHandler::handleRequest(HTTPServerRequest & request, HTTPServerResponse & response) { HTMLForm params(request, request.getStream()); LOG_TRACE(log, "Request URI: {}", request.getURI()); auto process_error = [&response, this](const std::string & message) { response.setStatusAndReason(Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR); if (!response.sent()) *response.send() << message << std::endl; LOG_WARNING(log, message); }; if (!params.has("connection_string")) { process_error("No 'connection_string' in request URL"); return; } try { std::string connection_string = params.get("connection_string"); nanodbc::connection connection(validateODBCConnectionString(connection_string)); auto identifier = getIdentifierQuote(connection); WriteBufferFromHTTPServerResponse out(response, request.getMethod() == Poco::Net::HTTPRequest::HTTP_HEAD, keep_alive_timeout); try { writeStringBinary(identifier, out); out.finalize(); } catch (...) { out.finalize(); } } catch (...) { process_error("Error getting identifier quote style from ODBC '" + getCurrentExceptionMessage(false) + "'"); tryLogCurrentException(log); } } } #endif