2017-04-01 09:19:00 +00:00
|
|
|
#include <IO/HTTPCommon.h>
|
2016-12-30 20:52:56 +00:00
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Common/config.h>
|
2018-05-14 18:36:01 +00:00
|
|
|
#if USE_POCO_NETSSL
|
2017-02-27 21:07:57 +00:00
|
|
|
#include <Poco/Net/AcceptCertificateHandler.h>
|
|
|
|
#include <Poco/Net/Context.h>
|
|
|
|
#include <Poco/Net/InvalidCertificateHandler.h>
|
|
|
|
#include <Poco/Net/PrivateKeyPassphraseHandler.h>
|
|
|
|
#include <Poco/Net/RejectCertificateHandler.h>
|
|
|
|
#include <Poco/Net/SSLManager.h>
|
2017-03-28 20:30:57 +00:00
|
|
|
#endif
|
|
|
|
#include <Poco/Net/HTTPServerResponse.h>
|
2017-02-27 21:07:57 +00:00
|
|
|
#include <Poco/Util/Application.h>
|
2017-01-30 05:13:58 +00:00
|
|
|
|
2016-12-30 20:52:56 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2017-09-08 16:41:35 +00:00
|
|
|
void setResponseDefaultHeaders(Poco::Net::HTTPServerResponse & response, unsigned keep_alive_timeout)
|
2016-12-31 02:05:37 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
if (!response.getKeepAlive())
|
|
|
|
return;
|
2016-12-30 20:52:56 +00:00
|
|
|
|
2017-09-08 11:57:43 +00:00
|
|
|
Poco::Timespan timeout(keep_alive_timeout, 0);
|
|
|
|
if (timeout.totalSeconds())
|
|
|
|
response.set("Keep-Alive", "timeout=" + std::to_string(timeout.totalSeconds()));
|
2016-12-30 20:52:56 +00:00
|
|
|
}
|
|
|
|
|
2017-03-07 19:01:37 +00:00
|
|
|
std::once_flag ssl_init_once;
|
2017-02-27 21:07:57 +00:00
|
|
|
|
2017-03-07 19:01:37 +00:00
|
|
|
void SSLInit()
|
2017-02-27 21:07:57 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
// http://stackoverflow.com/questions/18315472/https-request-in-c-using-poco
|
2018-05-14 18:36:01 +00:00
|
|
|
#if USE_POCO_NETSSL
|
2017-04-01 07:20:54 +00:00
|
|
|
Poco::Net::initializeSSL();
|
2017-03-28 20:30:57 +00:00
|
|
|
#endif
|
2017-02-27 21:07:57 +00:00
|
|
|
}
|
2016-12-30 20:52:56 +00:00
|
|
|
}
|