1#pragma once
2
3#include <memory>
4#include <Poco/Logger.h>
5#include <Poco/Net/HTTPRequestHandler.h>
6#include <Common/CurrentMetrics.h>
7
8
9namespace CurrentMetrics
10{
11 extern const Metric InterserverConnection;
12}
13
14namespace DB
15{
16
17class IServer;
18class WriteBufferFromHTTPServerResponse;
19
20class InterserverIOHTTPHandler : public Poco::Net::HTTPRequestHandler
21{
22public:
23 explicit InterserverIOHTTPHandler(IServer & server_)
24 : server(server_)
25 , log(&Poco::Logger::get("InterserverIOHTTPHandler"))
26 {
27 }
28
29 void handleRequest(Poco::Net::HTTPServerRequest & request, Poco::Net::HTTPServerResponse & response) override;
30
31private:
32 struct Output
33 {
34 std::shared_ptr<WriteBufferFromHTTPServerResponse> out;
35 };
36
37 IServer & server;
38 Poco::Logger * log;
39
40 CurrentMetrics::Increment metric_increment{CurrentMetrics::InterserverConnection};
41
42 void processQuery(Poco::Net::HTTPServerRequest & request, Poco::Net::HTTPServerResponse & response, Output & used_output);
43
44 std::pair<String, bool> checkAuthentication(Poco::Net::HTTPServerRequest & request) const;
45};
46
47}
48