Skip to content

Commit 41eeb4a

Browse files
Merge pull request #157 from tencentyun/feature_huberyxxiao_b3b34cad
Feature huberyxxiao b3b34cad
2 parents b03bdb2 + 27f45da commit 41eeb4a

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

include/op/base_op.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class BaseOp {
121121
std::istream& is, BaseResp* resp, const SharedTransferHandler& handler = nullptr);
122122

123123
std::string GetRealUrl(const std::string& host, const std::string& path,
124-
bool is_https);
124+
bool is_https, bool is_generate_presigned_url = false);
125125

126126
protected:
127127
bool CheckConfigValidation() const;

src/op/base_op.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ CosResult BaseOp::UploadAction(
350350

351351
// 1. host优先级,私有ip > 自定义域名 > DNS cache > 默认域名
352352
std::string BaseOp::GetRealUrl(const std::string& host, const std::string& path,
353-
bool is_https) {
353+
bool is_https, bool is_generate_presigned_url) {
354354
std::string dest_uri;
355355
std::string dest_host = host;
356356
std::string dest_path = path;
@@ -366,17 +366,17 @@ std::string BaseOp::GetRealUrl(const std::string& host, const std::string& path,
366366
if (m_config &&
367367
m_config->GetSetIntranetOnce() &&
368368
m_config->IsUseIntranet() &&
369-
!m_config->GetIntranetAddr().empty()) {
369+
!m_config->GetIntranetAddr().empty() && !is_generate_presigned_url) {
370370
dest_host = m_config->GetIntranetAddr();
371371
} else if (CosSysConfig::IsUseIntranet() &&
372-
!CosSysConfig::GetIntranetAddr().empty()) {
372+
!CosSysConfig::GetIntranetAddr().empty() && !is_generate_presigned_url) {
373373
dest_host = CosSysConfig::GetIntranetAddr();
374374
} else if (m_config &&
375375
(!m_config->GetDestDomain().empty())) {
376376
dest_host = m_config->GetDestDomain();
377377
} else if (!CosSysConfig::GetDestDomain().empty()) {
378378
dest_host = CosSysConfig::GetDestDomain();
379-
} else if (CosSysConfig::GetUseDnsCache()) {
379+
} else if (CosSysConfig::GetUseDnsCache() && !is_generate_presigned_url) {
380380
dest_host = GetGlobalDnsCacheInstance().Resolve(host);
381381
}
382382

src/op/object_op.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1811,7 +1811,7 @@ std::string ObjectOp::GeneratePresignedUrl(const GeneratePresignedUrlReq& req) {
18111811
return "";
18121812
}
18131813

1814-
std::string signed_url = GetRealUrl(host, req.GetPath(), req.UseHttps());
1814+
std::string signed_url = GetRealUrl(host, req.GetPath(), req.UseHttps(), true);
18151815
signed_url += "?sign=" + CodecUtil::EncodeKey(auth_str);
18161816

18171817
const std::map<std::string, std::string>& req_params = req.GetParams();

0 commit comments

Comments
 (0)