2016-12-30 20:52:56 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-02-27 21:07:57 +00:00
|
|
|
#include <mutex>
|
2018-06-14 21:20:39 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include <Poco/Net/HTTPClientSession.h>
|
|
|
|
#include <Poco/Net/HTTPRequest.h>
|
|
|
|
#include <Poco/Net/HTTPResponse.h>
|
|
|
|
#include <Poco/URI.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include <IO/ConnectionTimeouts.h>
|
2017-01-30 05:13:58 +00:00
|
|
|
|
|
|
|
namespace Poco
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
namespace Net
|
|
|
|
{
|
|
|
|
class HTTPServerResponse;
|
|
|
|
}
|
2017-01-30 05:13:58 +00:00
|
|
|
}
|
|
|
|
|
2016-12-30 20:52:56 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2018-06-14 21:20:39 +00:00
|
|
|
const int HTTP_TOO_MANY_REQUESTS = 429;
|
|
|
|
|
2017-09-08 16:41:35 +00:00
|
|
|
void setResponseDefaultHeaders(Poco::Net::HTTPServerResponse & response, unsigned keep_alive_timeout);
|
2016-12-30 20:52:56 +00:00
|
|
|
|
2017-02-27 21:07:57 +00:00
|
|
|
|
2018-06-16 05:54:06 +00:00
|
|
|
/// Create session object to perform requests and set required parameters.
|
|
|
|
std::unique_ptr<Poco::Net::HTTPClientSession> makeHTTPSession(const Poco::URI & uri, const ConnectionTimeouts & timeouts);
|
|
|
|
|
|
|
|
|
|
|
|
/** Used to receive response (response headers and possibly body)
|
|
|
|
* after sending data (request headers and possibly body).
|
|
|
|
* Throws exception in case of non HTTP_OK (200) response code.
|
|
|
|
* Returned istream lives in 'session' object.
|
|
|
|
*/
|
|
|
|
std::istream * receiveResponse(Poco::Net::HTTPClientSession & session, const Poco::Net::HTTPRequest & request, Poco::Net::HTTPResponse & response);
|
2018-06-14 21:20:39 +00:00
|
|
|
|
2016-12-30 20:52:56 +00:00
|
|
|
}
|