From f0de9adfc60fc2f126b8bc0729b364ea6896e310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=9B=BD=E4=BC=9F?= <366193849@qq.com> Date: Mon, 11 Oct 2021 13:30:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dunix=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E8=AE=BF=E9=97=AE=E5=B8=A6-=E7=9A=84?= =?UTF-8?q?=E5=9F=9F=E5=90=8D=E7=9A=84bug=20(#68)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FastGithub.HttpServer/HttpProxyMiddleware.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/FastGithub.HttpServer/HttpProxyMiddleware.cs b/FastGithub.HttpServer/HttpProxyMiddleware.cs index a4f11f4..3c6fbda 100644 --- a/FastGithub.HttpServer/HttpProxyMiddleware.cs +++ b/FastGithub.HttpServer/HttpProxyMiddleware.cs @@ -3,10 +3,12 @@ using FastGithub.DomainResolve; using Microsoft.AspNetCore.Connections.Features; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; +using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; using System.IO.Pipelines; using System.Net; using System.Net.Http; using System.Net.Sockets; +using System.Reflection; using System.Text; using System.Threading.Tasks; using Yarp.ReverseProxy.Forwarder; @@ -28,6 +30,20 @@ namespace FastGithub.HttpServer private readonly HttpMessageInvoker defaultHttpClient; + static HttpProxyMiddleware() + { + // https://github.com/dotnet/aspnetcore/issues/37421 + var authority = typeof(HttpParser<>).Assembly + .GetType("Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.HttpCharacters")? + .GetField("_authority", BindingFlags.NonPublic | BindingFlags.Static)? + .GetValue(null); + + if (authority is bool[] authorityArray) + { + authorityArray['-'] = true; + } + } + /// /// http代理中间件 ///