ClickHouse/src/IO/WriteBufferFromHTTP.h

41 lines
1.3 KiB
C++
Raw Normal View History

2018-06-15 07:05:14 +00:00
#pragma once
#include <IO/ConnectionTimeouts.h>
#include <IO/WriteBuffer.h>
#include <IO/WriteBufferFromOStream.h>
#include <IO/HTTPCommon.h>
#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
const std::string & content_type = "",
2022-02-12 02:43:53 +00:00
const std::string & content_encoding = "",
const HTTPHeaderEntries & additional_headers = {},
2021-11-10 22:58:56 +00:00
const ConnectionTimeouts & timeouts = {},
Add global proxy setting (#51749) * initial impl * fix env ut * move ut directory * make sure no null proxy resolver is returned by ProxyConfigurationResolverProvider * minor adjustment * add a few tests, still incomplete * add proxy support for url table function * use proxy for select from url as well * remove optional from return type, just returns empty config * fix style * style * black * ohg boy * rm in progress file * god pls don't let me kill anyone * ... * add use_aws guards * remove hard coded s3 proxy resolver * add concurrency-mt-unsafe * aa * black * add logging back * revert change * imrpove code a bit * helper functions and separate tests * for some reason, this env test is not working.. * formatting * :) * clangtidy * lint * revert some stupid things * small test adjusmtments * simplify tests * rename test * remove extra line * freaking style change * simplify a bit * fix segfault & remove an extra call * tightly couple proxy provider with context.. * remove useless include * rename config prefix parameter * simplify provider a bit * organize provider a bit * add a few comments * comment out proxy env tests * fix nullptr in unit tests * make sure old storage proxy config is properly covered without global context instance * move a few functions from class to anonymous namespace * fix no fallback for specific storage conf * change API to accept http method instead of bool * implement http/https distinction in listresolver, any still not implemented * implement http/https distinction in remote resolver * progress on code, improve tests and add url function working test * use protcol instead of method for http and https * small fix * few more adjustments * fix style * black * move enum to proxyconfiguration * wip * fix build * fix ut * delete atomicroundrobin class * remove stale include * add some tests.. need to spend some more time on the design.. * change design a bit * progress * use existing context for tests * rename aux function and fix ut * .. * rename test * try to simplify tests a bit * simplify tests a bit more * attempt to fix tests, accept more than one remote resolver * use proper log id * try waiting for resolver * proper wait logic * black * empty * address a few comments * refactor tests * remove old tests * baclk * use RAII to set/unset env * black * clang tidy * fix env proxy not respecting any * use log trace * fix wrong logic in getRemoteREsolver * fix wrong logic in getRemoteREsolver * fix test * remove unwanted code * remove ClientConfigurationperRequest and auxilary classes * remove unwanted code * remove adapter test * few adjustments and add test for s3 storage conf with new proxy settings * black * use chassert for context * Add getenv comment
2023-08-24 13:07:26 +00:00
size_t buffer_size_ = DBMS_DEFAULT_BUFFER_SIZE,
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
}