2018-06-15 07:05:14 +00:00
|
|
|
#include <IO/WriteBufferFromHTTP.h>
|
|
|
|
|
2022-04-27 15:05:45 +00:00
|
|
|
#include <Common/logger_useful.h>
|
2018-06-15 07:05:14 +00:00
|
|
|
|
2018-06-16 05:54:06 +00:00
|
|
|
|
2018-06-15 07:05:14 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
2018-06-16 05:54:06 +00:00
|
|
|
|
2018-06-15 07:05:14 +00:00
|
|
|
WriteBufferFromHTTP::WriteBufferFromHTTP(
|
2021-12-06 08:31:47 +00:00
|
|
|
const Poco::URI & uri,
|
|
|
|
const std::string & method,
|
2021-12-02 07:49:34 +00:00
|
|
|
const std::string & content_type,
|
2022-02-12 02:43:53 +00:00
|
|
|
const std::string & content_encoding,
|
2021-12-06 08:20:10 +00:00
|
|
|
const ConnectionTimeouts & timeouts,
|
2021-12-02 07:49:34 +00:00
|
|
|
size_t buffer_size_)
|
2018-06-15 07:05:14 +00:00
|
|
|
: WriteBufferFromOStream(buffer_size_)
|
2018-06-16 05:54:06 +00:00
|
|
|
, session{makeHTTPSession(uri, timeouts)}
|
2018-06-15 07:05:14 +00:00
|
|
|
, request{method, uri.getPathAndQuery(), Poco::Net::HTTPRequest::HTTP_1_1}
|
|
|
|
{
|
|
|
|
request.setHost(uri.getHost());
|
|
|
|
request.setChunkedTransferEncoding(true);
|
|
|
|
|
2021-12-02 07:49:34 +00:00
|
|
|
if (!content_type.empty())
|
|
|
|
{
|
|
|
|
request.set("Content-Type", content_type);
|
|
|
|
}
|
|
|
|
|
2022-02-12 02:43:53 +00:00
|
|
|
if (!content_encoding.empty())
|
|
|
|
request.set("Content-Encoding", content_encoding);
|
2022-02-11 09:45:49 +00:00
|
|
|
|
2020-05-30 21:57:37 +00:00
|
|
|
LOG_TRACE((&Poco::Logger::get("WriteBufferToHTTP")), "Sending request to {}", uri.toString());
|
2018-06-15 07:05:14 +00:00
|
|
|
|
|
|
|
ostr = &session->sendRequest(request);
|
|
|
|
}
|
2018-06-16 05:54:06 +00:00
|
|
|
|
2021-11-10 22:58:56 +00:00
|
|
|
void WriteBufferFromHTTP::finalizeImpl()
|
2018-06-15 07:05:14 +00:00
|
|
|
{
|
2022-02-11 09:45:49 +00:00
|
|
|
// for compressed body, the data is stored in buffered first
|
|
|
|
// here, make sure the content in the buffer has been flushed
|
|
|
|
this->nextImpl();
|
|
|
|
|
2019-09-16 17:28:41 +00:00
|
|
|
receiveResponse(*session, request, response, false);
|
2018-06-16 05:54:06 +00:00
|
|
|
/// TODO: Response body is ignored.
|
2018-06-15 07:05:14 +00:00
|
|
|
}
|
2018-06-16 05:54:06 +00:00
|
|
|
|
2018-06-15 07:05:14 +00:00
|
|
|
}
|