diff --git a/src/framework/chef.c b/src/framework/chef.c index 6a78794..886fef3 100644 --- a/src/framework/chef.c +++ b/src/framework/chef.c @@ -3,9 +3,9 @@ * ------------------------------------------------------------- * File Name : chef.c * File Authors : 曾奥然 - * Contributors : Nul None + * Contributors : BingChunMoLi * Created On : <2025-08-09> - * Last Modified : <2025-08-22> + * Last Modified : <2025-08-27> * * chef DSL: for chefs (recipe makers) to define a target * ------------------------------------------------------------*/ @@ -374,3 +374,15 @@ chef_set_sources_last_updated (Target_t *target, char *date) target->sources_last_updated = xy_strdup (date); } + + +/** + * @note 某些 target 需要修改 User-Agent + * 由于单独测速 (chsrc measure) 的时候也需要进行此项修改, + * 所以该函数不能仅仅放在 _setsrc() 里,而是应当放在 _prelude() 里 + */ +void +chef_set_user_agent (char *user_agent) +{ + ProgStatus.user_agent = user_agent; +} diff --git a/src/framework/core.c b/src/framework/core.c index 62ed6c3..c4f5486 100644 --- a/src/framework/core.c +++ b/src/framework/core.c @@ -1112,11 +1112,6 @@ chsrc_determine_chgtype (ChgType_t type) ProgStatus.chgtype = chsrc_in_reset_mode() ? ChgType_Reset : type; } -void -chsrc_custom_user_agent (char *user_agent) -{ - ProgStatus.user_agent = user_agent; -} #define MSG_EN_PUBLIC_URL "If the URL you specify is a public service, you are invited to contribute: chsrc issue" #define MSG_CN_PUBLIC_URL "若您指定的URL为公有服务,邀您参与贡献: chsrc issue" diff --git a/src/recipe/lang/Java.c b/src/recipe/lang/Java.c index 120ce8b..462952e 100644 --- a/src/recipe/lang/Java.c +++ b/src/recipe/lang/Java.c @@ -20,7 +20,9 @@ pl_java_prelude () chef_allow_local_mode (this, CanNot, NULL, NULL); chef_forbid_english(this); chef_allow_user_define(this); - chsrc_custom_user_agent("Maven/3.9.11"); + + // HuaweiCDN 需要该项 + chef_set_user_agent ("Maven/3.9.11"); def_sources_begin() {&UpstreamProvider, "https://repo1.maven.org/maven2/", DelegateToUpstream},