MCPcopy Create free account
hub / github.com/ByConity/ByConity / handleRequest

Method handleRequest

programs/odbc-bridge/MainHandler.cpp:51–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49
50
51void ODBCHandler::handleRequest(HTTPServerRequest & request, HTTPServerResponse & response)
52{
53 HTMLForm params(getContext()->getSettingsRef(), request);
54 LOG_TRACE(log, "Request URI: {}", request.getURI());
55
56 if (mode == "read")
57 params.read(request.getStream());
58
59 if (mode == "read" && !params.has("query"))
60 {
61 processError(response, "No 'query' in request body");
62 return;
63 }
64
65
66 if (!params.has("connection_string"))
67 {
68 processError(response, "No 'connection_string' in request URL");
69 return;
70 }
71
72 if (!params.has("sample_block"))
73 {
74 processError(response, "No 'sample_block' in request URL");
75 return;
76 }
77
78 std::string format = params.get("format", "RowBinary");
79 std::string connection_string = params.get("connection_string");
80 LOG_TRACE(log, "Connection string: '{}'", connection_string);
81
82 UInt64 max_block_size = DEFAULT_BLOCK_SIZE;
83 if (params.has("max_block_size"))
84 {
85 std::string max_block_size_str = params.get("max_block_size", "");
86 if (max_block_size_str.empty())
87 {
88 processError(response, "Empty max_block_size specified");
89 return;
90 }
91 max_block_size = parse<size_t>(max_block_size_str);
92 }
93
94 std::string sample_block_string = params.get("sample_block");
95 std::unique_ptr<Block> sample_block;
96 try
97 {
98 sample_block = parseColumns(std::move(sample_block_string));
99 }
100 catch (const Exception & ex)
101 {
102 processError(response, "Invalid 'sample_block' parameter in request body '" + ex.message() + "'");
103 LOG_ERROR(log, ex.getStackTraceString());
104 return;
105 }
106
107 WriteBufferFromHTTPServerResponse out(response, request.getMethod() == Poco::Net::HTTPRequest::HTTP_HEAD, keep_alive_timeout);
108

Callers

nothing calls this directly

Calls 15

processErrorFunction · 0.85
getQuotingStyleFunction · 0.85
writeStringBinaryFunction · 0.85
tryLogCurrentExceptionFunction · 0.85
getStreamMethod · 0.80
getStackTraceStringMethod · 0.80
parseColumnsFunction · 0.70
copyDataFunction · 0.50
readMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected