ClickHouse/dbms/include/DB/IO/ReadBufferFromHTTP.h

49 lines
1.1 KiB
C++
Raw Normal View History

#pragma once
#include <memory>
#include <Poco/Net/HTTPClientSession.h>
#include <DB/IO/ReadBuffer.h>
#include <DB/Core/Types.h>
#define DEFAULT_HTTP_READ_BUFFER_TIMEOUT 1800
#define DEFAULT_HTTP_READ_BUFFER_CONNECTION_TIMEOUT 1
namespace DB
{
/** Perform HTTP-request and provide response to read.
*/
class ReadBufferFromHTTP : public ReadBuffer
{
private:
String host;
int port;
2016-11-15 23:55:45 +00:00
String path;
2016-11-16 00:34:57 +00:00
String method;
Poco::Net::HTTPClientSession session;
std::istream * istr; /// owned by session
std::unique_ptr<ReadBuffer> impl;
public:
using Params = std::vector<std::pair<String, String>>;
2014-04-02 13:45:39 +00:00
ReadBufferFromHTTP(
const String & host_,
int port_,
2016-11-15 23:55:45 +00:00
const String & path_,
2014-04-02 13:45:39 +00:00
const Params & params,
2016-11-15 23:55:45 +00:00
const String & method_ = "",
size_t buffer_size_ = DBMS_DEFAULT_BUFFER_SIZE,
const Poco::Timespan & connection_timeout = Poco::Timespan(DEFAULT_HTTP_READ_BUFFER_CONNECTION_TIMEOUT, 0),
const Poco::Timespan & send_timeout = Poco::Timespan(DEFAULT_HTTP_READ_BUFFER_TIMEOUT, 0),
const Poco::Timespan & receive_timeout = Poco::Timespan(DEFAULT_HTTP_READ_BUFFER_TIMEOUT, 0));
bool nextImpl() override;
};
}