mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Merge pull request #12256 from ianton-ru/redirect_limit_exception
throw exception on redirect limit in S3 request
This commit is contained in:
commit
f04a49a114
@ -14,6 +14,11 @@
|
||||
#include <Poco/Net/HTTPResponse.h>
|
||||
#include <common/logger_useful.h>
|
||||
|
||||
namespace DB::ErrorCodes
|
||||
{
|
||||
extern const int TOO_MANY_REDIRECTS;
|
||||
}
|
||||
|
||||
namespace DB::S3
|
||||
{
|
||||
PocoHTTPClient::PocoHTTPClient(const Aws::Client::ClientConfiguration & clientConfiguration)
|
||||
@ -153,8 +158,10 @@ void PocoHTTPClient::MakeRequestInternal(
|
||||
else
|
||||
response->GetResponseStream().SetUnderlyingStream(std::make_shared<PocoHTTPResponseStream>(session, response_body_stream));
|
||||
|
||||
break;
|
||||
return;
|
||||
}
|
||||
throw Exception(String("Too many redirects while trying to access ") + request.GetUri().GetURIString(),
|
||||
ErrorCodes::TOO_MANY_REDIRECTS);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
@ -1,4 +1,11 @@
|
||||
from bottle import abort, route, run, request
|
||||
from bottle import abort, route, run, request, response
|
||||
|
||||
|
||||
@route('/redirected/<_path>')
|
||||
def infinite_redirect(_path):
|
||||
response.set_header("Location", request.url)
|
||||
response.status = 307
|
||||
return 'Redirected'
|
||||
|
||||
|
||||
@route('/<_bucket>/<_path>')
|
||||
|
@ -336,3 +336,19 @@ def test_get_csv_default(cluster):
|
||||
instance = cluster.instances["dummy"] # type: ClickHouseInstance
|
||||
result = run_query(instance, get_query)
|
||||
assert result == '1\t2\t3\n'
|
||||
|
||||
|
||||
def test_infinite_redirect(cluster):
|
||||
bucket = "redirected"
|
||||
table_format = "column1 UInt32, column2 UInt32, column3 UInt32"
|
||||
filename = "test.csv"
|
||||
get_query = "select * from s3('http://resolver:8080/{bucket}/{file}', 'CSV', '{table_format}')".format(
|
||||
bucket="redirected",
|
||||
file=filename,
|
||||
table_format=table_format)
|
||||
instance = cluster.instances["dummy"] # type: ClickHouseInstance
|
||||
try:
|
||||
result = run_query(instance, get_query)
|
||||
except Exception as e:
|
||||
assert str(e).find("Too many redirects while trying to access") != -1
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user