ClickHouse/dbms/src/Server/HTTPHandler.h

55 lines
1.2 KiB
C++
Raw Normal View History

2012-03-09 03:06:09 +00:00
#pragma once
#include <DB/Common/CurrentMetrics.h>
2012-03-09 03:06:09 +00:00
#include "Server.h"
namespace CurrentMetrics
{
extern const Metric HTTPConnection;
}
2012-03-09 03:06:09 +00:00
namespace DB
{
class WriteBufferFromHTTPServerResponse;
2012-03-09 15:46:52 +00:00
class HTTPHandler : public Poco::Net::HTTPRequestHandler
2012-03-09 03:06:09 +00:00
{
public:
2012-03-09 15:46:52 +00:00
HTTPHandler(Server & server_)
2012-03-09 03:06:09 +00:00
: server(server_)
2012-03-09 15:46:52 +00:00
, log(&Logger::get("HTTPHandler"))
2012-03-09 03:06:09 +00:00
{
}
struct Output
{
std::shared_ptr<WriteBufferFromHTTPServerResponse> out;
/// Used for sending response. Points to 'out', or to CompressedWriteBuffer(*out), depending on settings.
std::shared_ptr<WriteBuffer> out_maybe_compressed;
};
void handleRequest(Poco::Net::HTTPServerRequest & request, Poco::Net::HTTPServerResponse & response) override;
void trySendExceptionToClient(const std::string & s, int exception_code,
Poco::Net::HTTPServerRequest & request, Poco::Net::HTTPServerResponse & response,
Output & used_output);
2012-03-09 03:06:09 +00:00
private:
Server & server;
CurrentMetrics::Increment metric_increment{CurrentMetrics::HTTPConnection};
2012-03-09 03:06:09 +00:00
Logger * log;
/// Also initializes 'used_output'.
void processQuery(
Poco::Net::HTTPServerRequest & request,
HTMLForm & params,
Poco::Net::HTTPServerResponse & response,
Output & used_output);
2012-03-09 03:06:09 +00:00
};
}