Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mirai http 插件升到最新版本(2.10.0)报错,Post请求时增加{ "Content-Type", "application… #88

Merged
merged 3 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Mirai.Net/Mirai.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<LangVersion>latest</LangVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageVersion>2.5.1</PackageVersion>
<PackageVersion>2.5.2</PackageVersion>
<Title>Mirai.Net</Title>
<LangVersion>latest</LangVersion>
<Description>基于mirai-api-http的轻量级mirai社区sdk</Description>
Expand Down
9 changes: 7 additions & 2 deletions Mirai.Net/Utils/Internal/MiraiHttpUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Mirai.Net.Sessions;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using NullValueHandling = Newtonsoft.Json.NullValueHandling;

Expand Down Expand Up @@ -116,12 +117,16 @@ public static async Task<string> PostJsonAsync(string url, object json, bool wit
{
var result = withSessionKey
? await url
.WithHeader("Authorization", $"session {MiraiBot.Instance.HttpSessionKey}")
.WithHeaders(new Dictionary<string, string>() { { "Content-Type", "application/json" }
yukuyoulei marked this conversation as resolved.
Show resolved Hide resolved
, { "Authorization", $"session {MiraiBot.Instance.HttpSessionKey}" }
})
.PostStringAsync(json.ToJsonString(new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
}))
: await url.PostStringAsync(json.ToJsonString(new JsonSerializerSettings
: await url
.WithHeaders(new Dictionary<string, string>() { { "Content-Type", "application/json" } })
.PostStringAsync(json.ToJsonString(new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
}));
Expand Down