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

Method handleRequest

src/Server/InterserverIOHTTPHandler.cpp:85–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83
84
85void InterserverIOHTTPHandler::handleRequest(HTTPServerRequest & request, HTTPServerResponse & response, const ProfileEvents::Event & write_event)
86{
87 DB::setThreadName(ThreadName::INTERSERVER_HANDLER);
88
89 /// In order to work keep-alive.
90 if (request.getVersion() == HTTPServerRequest::HTTP_1_1)
91 response.setChunkedTransferEncoding(true);
92
93 auto output = std::make_shared<WriteBufferFromHTTPServerResponse>(
94 response, request.getMethod() == Poco::Net::HTTPRequest::HTTP_HEAD, write_event);
95
96 try
97 {
98 auto [message, success] = checkAuthentication(request);
99 if (success)
100 {
101 processQuery(request, response, output);
102 output->finalize();
103 LOG_DEBUG(log, "Done processing query");
104 }
105 else
106 {
107 LOG_WARNING(log, "Query processing failed request: '{}' authentication failed", request.getURI());
108 output->cancelWithException(request, ErrorCodes::REQUIRED_PASSWORD, message, nullptr);
109 }
110 }
111 catch (Exception & e)
112 {
113 /// Sending to remote server was cancelled due to server shutdown or drop table.
114 bool is_real_error = e.code() != ErrorCodes::ABORTED;
115 PreformattedMessage message = getCurrentExceptionMessageAndPattern(/* with_stacktrace */ is_real_error);
116 if (is_real_error)
117 LOG_ERROR(log, message);
118 else
119 LOG_INFO(log, message);
120
121 output->cancelWithException(request, getCurrentExceptionCode(), message.text, nullptr);
122 }
123 catch (...)
124 {
125 PreformattedMessage message = getCurrentExceptionMessageAndPattern(/* with_stacktrace */ false);
126 LOG_ERROR(log, message);
127
128 output->cancelWithException(request, getCurrentExceptionCode(), message.text, nullptr);
129 }
130}
131
132
133}

Callers

nothing calls this directly

Calls 9

getCurrentExceptionCodeFunction · 0.85
getURIMethod · 0.80
cancelWithExceptionMethod · 0.80
setThreadNameFunction · 0.50
getVersionMethod · 0.45
finalizeMethod · 0.45
codeMethod · 0.45

Tested by

no test coverage detected