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

Function getUriAfterRedirect

src/IO/ReadWriteBufferFromHTTP.cpp:36–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36Poco::URI getUriAfterRedirect(const Poco::URI & prev_uri, Poco::Net::HTTPResponse & response, bool enable_url_encoding)
37{
38 chassert(DB::isRedirect(response.getStatus()));
39
40 auto location = response.get("Location");
41 auto location_uri = Poco::URI(location, enable_url_encoding);
42 if (!location_uri.isRelative())
43 return location_uri;
44 /// Location header contains relative path. So we need to concatenate it
45 /// with path from the original URI and normalize it.
46 auto path = std::filesystem::weakly_canonical(std::filesystem::path(prev_uri.getPath()) / location);
47 location_uri = prev_uri;
48 location_uri.setPath(path);
49 return location_uri;
50}
51
52class ReadBufferFromSessionResponse : public DB::ReadBufferFromIStream
53{

Callers 1

callWithRedirectsMethod · 0.85

Calls 7

isRedirectFunction · 0.85
URIClass · 0.50
getStatusMethod · 0.45
getMethod · 0.45
isRelativeMethod · 0.45
getPathMethod · 0.45
setPathMethod · 0.45

Tested by

no test coverage detected