HTTPServer.cpp 1.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
#include <Server/HTTP/HTTPServer.h>

#include <Server/HTTP/HTTPServerConnectionFactory.h>


namespace DB
{
HTTPServer::HTTPServer(
    const Context & context,
    HTTPRequestHandlerFactoryPtr factory_,
    UInt16 portNumber,
    Poco::Net::HTTPServerParams::Ptr params)
    : TCPServer(new HTTPServerConnectionFactory(context, params, factory_), portNumber, params), factory(factory_)
{
}

HTTPServer::HTTPServer(
    const Context & context,
    HTTPRequestHandlerFactoryPtr factory_,
    const Poco::Net::ServerSocket & socket,
    Poco::Net::HTTPServerParams::Ptr params)
    : TCPServer(new HTTPServerConnectionFactory(context, params, factory_), socket, params), factory(factory_)
{
}

HTTPServer::HTTPServer(
    const Context & context,
    HTTPRequestHandlerFactoryPtr factory_,
    Poco::ThreadPool & threadPool,
    const Poco::Net::ServerSocket & socket,
    Poco::Net::HTTPServerParams::Ptr params)
    : TCPServer(new HTTPServerConnectionFactory(context, params, factory_), threadPool, socket, params), factory(factory_)
{
}

HTTPServer::~HTTPServer()
{
    /// We should call stop and join thread here instead of destructor of parent TCPHandler,
    /// because there's possible race on 'vptr' between this virtual destructor and 'run' method.
    stop();
}

void HTTPServer::stopAll(bool /* abortCurrent */)
{
    stop();
}

}