Fixed GET redirects.

This commit is contained in:
Vladimir Chebotarev 2019-05-31 15:50:21 +00:00
parent 78f57c5f2a
commit caeacafb76
2 changed files with 7 additions and 6 deletions

View File

@ -31,7 +31,7 @@ namespace DB
namespace detail namespace detail
{ {
template <typename SessionPtr> template <typename SessionPtr>//FIXME Можно избавиться от template, или переделать на нормальное.
class ReadWriteBufferFromS3Base : public ReadBuffer class ReadWriteBufferFromS3Base : public ReadBuffer
{ {
protected: protected:
@ -45,8 +45,8 @@ namespace detail
public: public:
using OutStreamCallback = std::function<void(std::ostream &)>; using OutStreamCallback = std::function<void(std::ostream &)>;
explicit ReadWriteBufferFromS3Base(SessionPtr session_, explicit ReadWriteBufferFromS3Base(Poco::URI uri,
Poco::URI uri, const ConnectionTimeouts & timeouts = {},
const std::string & method = {}, const std::string & method = {},
OutStreamCallback out_stream_callback = {}, OutStreamCallback out_stream_callback = {},
const Poco::Net::HTTPBasicCredentials & credentials = {}, const Poco::Net::HTTPBasicCredentials & credentials = {},
@ -54,7 +54,7 @@ namespace detail
: ReadBuffer(nullptr, 0) : ReadBuffer(nullptr, 0)
, uri {uri} , uri {uri}
, method {!method.empty() ? method : out_stream_callback ? Poco::Net::HTTPRequest::HTTP_POST : Poco::Net::HTTPRequest::HTTP_GET} , method {!method.empty() ? method : out_stream_callback ? Poco::Net::HTTPRequest::HTTP_POST : Poco::Net::HTTPRequest::HTTP_GET}
, session {session_} , session(makeHTTPSession(uri, timeouts))
{ {
Poco::Net::HTTPResponse response; Poco::Net::HTTPResponse response;
std::unique_ptr<Poco::Net::HTTPRequest> request; std::unique_ptr<Poco::Net::HTTPRequest> request;
@ -91,6 +91,7 @@ namespace detail
break; break;
uri = location_iterator->second; uri = location_iterator->second;
session = makeHTTPSession(uri, timeouts);
} }
assertResponseIsOk(*request, response, istr); assertResponseIsOk(*request, response, istr);
@ -120,7 +121,7 @@ public:
const ConnectionTimeouts & timeouts = {}, const ConnectionTimeouts & timeouts = {},
const Poco::Net::HTTPBasicCredentials & credentials = {}, const Poco::Net::HTTPBasicCredentials & credentials = {},
size_t buffer_size_ = DBMS_DEFAULT_BUFFER_SIZE) size_t buffer_size_ = DBMS_DEFAULT_BUFFER_SIZE)
: Parent(makeHTTPSession(uri_, timeouts), uri_, method_, out_stream_callback, credentials, buffer_size_) : Parent(uri_, timeouts, method_, out_stream_callback, credentials, buffer_size_)
{ {
} }
}; };