MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / callWithRedirects

Method callWithRedirects

src/IO/ReadWriteBufferFromHTTP.cpp:288–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286}
287
288ReadWriteBufferFromHTTP::CallResult ReadWriteBufferFromHTTP::callWithRedirects(
289 Poco::Net::HTTPResponse & response, const String & method_, const std::optional<HTTPRange> & range)
290{
291 auto result = callImpl(response, method_, range, true);
292
293 while (isRedirect(response.getStatus()))
294 {
295 Poco::URI uri_redirect = getUriAfterRedirect(current_uri, response, enable_url_encoding);
296 ++redirects;
297 if (redirects > max_redirects)
298 throw Exception(
299 ErrorCodes::TOO_MANY_REDIRECTS,
300 "Too many redirects while trying to access {}."
301 " You can {} redirects by changing the setting 'max_http_get_redirects'."
302 " Example: `SET max_http_get_redirects = 10`."
303 " Redirects are restricted to prevent possible attack when a malicious server redirects to an internal resource, bypassing the authentication or firewall.",
304 initial_uri.toString(), max_redirects ? "increase the allowed maximum number of" : "allow");
305
306 current_uri = uri_redirect;
307 result = callImpl(response, method_, range, true);
308 }
309
310 return result;
311}
312
313
314void ReadWriteBufferFromHTTP::doWithRetries(std::function<void()> && callable,

Callers

nothing calls this directly

Calls 5

isRedirectFunction · 0.85
getUriAfterRedirectFunction · 0.85
ExceptionClass · 0.70
getStatusMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected