重命名为 chef_set_user_agent()

[GitHub #278]
This commit is contained in:
Aoran Zeng
2025-08-27 11:06:53 +08:00
parent 58ef09fadd
commit b309c46a4c
3 changed files with 17 additions and 8 deletions

View File

@@ -3,9 +3,9 @@
* ------------------------------------------------------------- * -------------------------------------------------------------
* File Name : chef.c * File Name : chef.c
* File Authors : 曾奥然 <ccmywish@qq.com> * File Authors : 曾奥然 <ccmywish@qq.com>
* Contributors : Nul None <nul@none.org> * Contributors : BingChunMoLi <bingchunmoli@bingchunmoli.com>
* Created On : <2025-08-09> * 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 * 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); 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;
}

View File

@@ -1112,11 +1112,6 @@ chsrc_determine_chgtype (ChgType_t type)
ProgStatus.chgtype = chsrc_in_reset_mode() ? ChgType_Reset : 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_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" #define MSG_CN_PUBLIC_URL "若您指定的URL为公有服务邀您参与贡献: chsrc issue"

View File

@@ -20,7 +20,9 @@ pl_java_prelude ()
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this); chef_forbid_english(this);
chef_allow_user_define(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() def_sources_begin()
{&UpstreamProvider, "https://repo1.maven.org/maven2/", DelegateToUpstream}, {&UpstreamProvider, "https://repo1.maven.org/maven2/", DelegateToUpstream},