mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-08 00:24:41 +00:00
414f470c79
* Refactoring: part 1 * Refactoring: part 2 * Handle request using ReadBuffer interface * Struggles with ReadBuffer's * Fix URI parsing * Implement parsing of multipart/form-data * Check HTTP_LENGTH_REQUIRED before eof() or will hang * Fix HTTPChunkedReadBuffer * Fix build and style * Fix test * Resist double-eof * Fix arcadian build
55 lines
1.4 KiB
C++
55 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <Interpreters/Context.h>
|
|
#include <Server/HTTP/HTTPRequestHandler.h>
|
|
|
|
#include <Poco/Logger.h>
|
|
|
|
#pragma GCC diagnostic push
|
|
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
|
#include <Poco/Data/SessionPool.h>
|
|
#pragma GCC diagnostic pop
|
|
|
|
namespace DB
|
|
{
|
|
/** Main handler for requests to ODBC driver
|
|
* requires connection_string and columns in request params
|
|
* and also query in request body
|
|
* response in RowBinary format
|
|
*/
|
|
class ODBCHandler : public HTTPRequestHandler
|
|
{
|
|
public:
|
|
using PoolPtr = std::shared_ptr<Poco::Data::SessionPool>;
|
|
using PoolMap = std::unordered_map<std::string, PoolPtr>;
|
|
|
|
ODBCHandler(std::shared_ptr<PoolMap> pool_map_,
|
|
size_t keep_alive_timeout_,
|
|
Context & context_,
|
|
const String & mode_)
|
|
: log(&Poco::Logger::get("ODBCHandler"))
|
|
, pool_map(pool_map_)
|
|
, keep_alive_timeout(keep_alive_timeout_)
|
|
, context(context_)
|
|
, mode(mode_)
|
|
{
|
|
}
|
|
|
|
void handleRequest(HTTPServerRequest & request, HTTPServerResponse & response) override;
|
|
|
|
private:
|
|
Poco::Logger * log;
|
|
|
|
std::shared_ptr<PoolMap> pool_map;
|
|
size_t keep_alive_timeout;
|
|
Context & context;
|
|
String mode;
|
|
|
|
static inline std::mutex mutex;
|
|
|
|
PoolPtr getPool(const std::string & connection_str);
|
|
void processError(HTTPServerResponse & response, const std::string & message);
|
|
};
|
|
|
|
}
|