Skip to content

Commit

Permalink
Merge pull request #848 from RayWangQvQ/develop
Browse files Browse the repository at this point in the history
[#847] DefaultRequestHeaders can not be null or empty
  • Loading branch information
RayWangQvQ authored Feb 22, 2025
2 parents d76206d + d56aa91 commit 794a01f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 2.2.1
-Fix[#847]: DefaultRequestHeaders can not be null or empty with dotnet 8
## 2.2.0
- Migrate from dotnet 6.0 to dotnet 8.0
- Add Bruno to document the APIs
Expand Down
2 changes: 1 addition & 1 deletion common.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<Authors>Ray</Authors>
<Version>2.2.0</Version>
<Version>2.2.1</Version>
<NoWarn>$(NoWarn);CS1591;CS0436</NoWarn>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ public static IServiceCollection AddBiliBiliClientApi(this IServiceCollection se
//bilibli
Action<IServiceProvider, HttpClient> config = (sp, c) => {
c.DefaultRequestHeaders.Add("User-Agent", sp.GetRequiredService<IOptionsMonitor<SecurityOptions>>().CurrentValue.UserAgent);
c.DefaultRequestHeaders.Add("Cookie", sp.GetRequiredService<BiliCookie>().ToString());
var ck = sp.GetRequiredService<BiliCookie>().ToString();
if(!string.IsNullOrWhiteSpace(ck)) c.DefaultRequestHeaders.Add("Cookie", ck);
};
Action<IServiceProvider, HttpClient> configApp = (sp, c) => {
c.DefaultRequestHeaders.Add("User-Agent", sp.GetRequiredService<IOptionsMonitor<SecurityOptions>>().CurrentValue.UserAgentApp);
c.DefaultRequestHeaders.Add("Cookie", sp.GetRequiredService<BiliCookie>().ToString());
var ck = sp.GetRequiredService<BiliCookie>().ToString();
if(!string.IsNullOrWhiteSpace(ck)) c.DefaultRequestHeaders.Add("Cookie", ck);
};

services.AddBiliBiliClientApi<IUserInfoApi>(BiliHosts.Api, config);
Expand Down

0 comments on commit 794a01f

Please sign in to comment.