1 | #pragma once |
---|---|
2 | |
3 | #include <IO/ConnectionTimeouts.h> |
4 | #include <IO/WriteBuffer.h> |
5 | #include <IO/WriteBufferFromOStream.h> |
6 | #include <IO/HTTPCommon.h> |
7 | #include <Poco/Net/HTTPClientSession.h> |
8 | #include <Poco/Net/HTTPRequest.h> |
9 | #include <Poco/Net/HTTPResponse.h> |
10 | #include <Poco/URI.h> |
11 | |
12 | |
13 | namespace DB |
14 | { |
15 | |
16 | /* Perform HTTP POST/PUT request. |
17 | */ |
18 | class WriteBufferFromHTTP : public WriteBufferFromOStream |
19 | { |
20 | private: |
21 | HTTPSessionPtr session; |
22 | Poco::Net::HTTPRequest request; |
23 | Poco::Net::HTTPResponse response; |
24 | |
25 | public: |
26 | explicit WriteBufferFromHTTP(const Poco::URI & uri, |
27 | const std::string & method = Poco::Net::HTTPRequest::HTTP_POST, // POST or PUT only |
28 | const ConnectionTimeouts & timeouts = {}, |
29 | size_t buffer_size_ = DBMS_DEFAULT_BUFFER_SIZE); |
30 | |
31 | /// Receives response from the server after sending all data. |
32 | void finalize(); |
33 | }; |
34 | |
35 | } |
36 |