| 34 | } |
| 35 | |
| 36 | Poco::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 | |
| 52 | class ReadBufferFromSessionResponse : public DB::ReadBufferFromIStream |
| 53 | { |
no test coverage detected