From 4b50dba5358f43529c79fd2bda8cad76b3b092d3 Mon Sep 17 00:00:00 2001 From: ishkong <19740260+ishkong@users.noreply.github.com> Date: Sat, 23 Nov 2024 19:59:57 +0800 Subject: [PATCH] [OneBot] Adjusting HTTP code to OneBot standards MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/botuniverse/onebot-11/blob/d4456ee706f9ada9c2dfde56a2bcfc69752600e4/communication/http.md?plain=1#L41 所有的POST content-type不支持都应该返回406,所以哪怕遇到lgr无法处理的,也应该返回406 --- Lagrange.OneBot/Core/Network/Service/HttpService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lagrange.OneBot/Core/Network/Service/HttpService.cs b/Lagrange.OneBot/Core/Network/Service/HttpService.cs index 6018a9e92..690f0a17c 100644 --- a/Lagrange.OneBot/Core/Network/Service/HttpService.cs +++ b/Lagrange.OneBot/Core/Network/Service/HttpService.cs @@ -128,7 +128,7 @@ private async Task HandleRequestAsync(HttpListenerContext context, CancellationT if (!MediaTypeHeaderValue.TryParse(request.ContentType, out var mediaType)) { Log.LogCannotParseMediaType(_logger, request.ContentType ?? string.Empty); - response.StatusCode = (int)HttpStatusCode.UnsupportedMediaType; + response.StatusCode = (int)HttpStatusCode.NotAcceptable; response.Close(); return; }