2018-06-15 07:05:14 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <IO/ConnectionTimeouts.h>
|
|
|
|
#include <IO/WriteBuffer.h>
|
|
|
|
#include <IO/WriteBufferFromOStream.h>
|
2018-11-16 13:15:17 +00:00
|
|
|
#include <IO/HTTPCommon.h>
|
2023-03-03 12:55:52 +00:00
|
|
|
#include <IO/HTTPHeaderEntries.h>
|
2018-06-15 07:05:14 +00:00
|
|
|
#include <Poco/Net/HTTPClientSession.h>
|
|
|
|
#include <Poco/Net/HTTPRequest.h>
|
|
|
|
#include <Poco/Net/HTTPResponse.h>
|
|
|
|
#include <Poco/URI.h>
|
|
|
|
|
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
|
|
|
/* Perform HTTP POST/PUT request.
|
|
|
|
*/
|
|
|
|
class WriteBufferFromHTTP : public WriteBufferFromOStream
|
|
|
|
{
|
|
|
|
public:
|
2018-06-16 06:00:51 +00:00
|
|
|
explicit WriteBufferFromHTTP(const Poco::URI & uri,
|
2021-11-10 22:58:56 +00:00
|
|
|
const std::string & method = Poco::Net::HTTPRequest::HTTP_POST, // POST or PUT only
|
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 = "",
|
2023-03-03 12:55:52 +00:00
|
|
|
const HTTPHeaderEntries & additional_headers = {},
|
2021-11-10 22:58:56 +00:00
|
|
|
const ConnectionTimeouts & timeouts = {},
|
2023-08-24 13:07:26 +00:00
|
|
|
size_t buffer_size_ = DBMS_DEFAULT_BUFFER_SIZE,
|
2023-11-04 17:47:52 +00:00
|
|
|
ProxyConfiguration proxy_configuration = {});
|
2018-06-15 07:05:14 +00:00
|
|
|
|
2021-11-10 22:58:56 +00:00
|
|
|
private:
|
2018-06-16 05:54:06 +00:00
|
|
|
/// Receives response from the server after sending all data.
|
2021-11-10 22:58:56 +00:00
|
|
|
void finalizeImpl() override;
|
|
|
|
|
|
|
|
HTTPSessionPtr session;
|
|
|
|
Poco::Net::HTTPRequest request;
|
|
|
|
Poco::Net::HTTPResponse response;
|
2018-06-15 07:05:14 +00:00
|
|
|
};
|
2018-06-16 05:54:06 +00:00
|
|
|
|
2018-06-15 07:05:14 +00:00
|
|
|
}
|