MCPcopy Create free account
hub / github.com/apache/cloudberry / S3Url

Method S3Url

gpcontrib/gpcloud/src/s3url.cpp:3–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include "s3url.h"
2
3S3Url::S3Url(const string &sourceUrl, bool useHttps, const string &version, const string &region)
4 : version(version), sourceUrl(sourceUrl), region(region) {
5 string schemaStr = useHttps ? "https" : "http";
6 FindAndReplace(this->sourceUrl, "s3://", schemaStr + "://");
7
8 // else it was initialized with urlRegion
9 if (this->version == "1") {
10 extractRegionFromUrl();
11 } else if (this->version.empty()) {
12 if (extractRegionFromUrl()) {
13 this->version = "1";
14 } else {
15 this->version = "2";
16 }
17 }
18
19 http_parser_url urlParser;
20 int result =
21 http_parser_parse_url(this->sourceUrl.c_str(), this->sourceUrl.length(), false, &urlParser);
22
23 S3_CHECK_OR_DIE(result == 0, S3RuntimeError,
24 "Failed to parse URL " + sourceUrl + " at field " +
25 std::to_string((unsigned long long)result));
26
27 this->schema = schemaStr;
28 this->host = extractField(&urlParser, UF_HOST);
29 this->port = extractField(&urlParser, UF_PORT);
30
31 if (this->port != "443" && !this->port.empty() && useHttps) {
32 S3WARN("You are using https on port '%s'", this->port.c_str());
33 }
34
35 extractBucket();
36 extractEncodedPrefix();
37}
38
39string S3Url::getFullUrlForCurl() const {
40 stringstream fullUrl;

Callers

nothing calls this directly

Calls 3

FindAndReplaceFunction · 0.85
http_parser_parse_urlFunction · 0.85
lengthMethod · 0.80

Tested by

no test coverage detected