mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-11-15 08:54:07 +00:00
s3 signv4 support uri endpoints (#2510)
This commit is contained in:
parent
4fe2652c6c
commit
7d2d4e8866
33
src/curl.cpp
33
src/curl.cpp
@ -2900,6 +2900,37 @@ std::string S3fsCurl::CalcSignature(const std::string& method, const std::string
|
||||
return s3fs_hex_lower(md.get(), md_len);
|
||||
}
|
||||
|
||||
std::string S3fsCurl::extractURI(const std::string& url) {
|
||||
// If the URL is empty, return "/"
|
||||
if (url.empty()) {
|
||||
return "/";
|
||||
}
|
||||
|
||||
// Find the position of "://"
|
||||
std::size_t protocol_pos = url.find("://");
|
||||
if (protocol_pos == std::string::npos) {
|
||||
// If "://" is not found, return "/"
|
||||
return "/";
|
||||
}
|
||||
|
||||
// Find the position of the first "/" after "://"
|
||||
std::size_t uri_pos = url.find('/', protocol_pos + 3);
|
||||
if (uri_pos == std::string::npos) {
|
||||
// If no "/" is found after the domain, return "/"
|
||||
return "/";
|
||||
}
|
||||
|
||||
// Extract the URI
|
||||
std::string uri = url.substr(uri_pos);
|
||||
|
||||
// Ensure the URI ends with "/"
|
||||
if (uri.back() != '/') {
|
||||
uri += '/';
|
||||
}
|
||||
|
||||
return uri;
|
||||
}
|
||||
|
||||
void S3fsCurl::insertV4Headers(const std::string& access_key_id, const std::string& secret_access_key, const std::string& access_token)
|
||||
{
|
||||
std::string server_path = type == REQTYPE::LISTBUCKET ? "/" : path;
|
||||
@ -2944,7 +2975,7 @@ void S3fsCurl::insertV4Headers(const std::string& access_key_id, const std::stri
|
||||
get_date_sigv3(strdate, date8601);
|
||||
|
||||
std::string contentSHA256 = payload_hash.empty() ? EMPTY_PAYLOAD_HASH : payload_hash;
|
||||
const std::string realpath = pathrequeststyle ? "/" + S3fsCred::GetBucket() + server_path : server_path;
|
||||
const std::string realpath = pathrequeststyle ? S3fsCurl::extractURI(s3host) + S3fsCred::GetBucket() + server_path : server_path;
|
||||
|
||||
//string canonical_headers, signed_headers;
|
||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "host", get_bucket_host().c_str());
|
||||
|
@ -233,6 +233,8 @@ class S3fsCurl
|
||||
static bool InitCryptMutex();
|
||||
static bool DestroyCryptMutex();
|
||||
static int CurlProgress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
|
||||
static std::string extractURI(const std::string& url);
|
||||
|
||||
|
||||
static bool LocateBundle();
|
||||
static size_t HeaderCallback(void *data, size_t blockSize, size_t numBlocks, void *userPtr);
|
||||
|
Loading…
Reference in New Issue
Block a user