diff --git a/FastGithub.Http/HttpClient.cs b/FastGithub.Http/HttpClient.cs
index 07074bd..7eb5232 100644
--- a/FastGithub.Http/HttpClient.cs
+++ b/FastGithub.Http/HttpClient.cs
@@ -43,14 +43,16 @@ namespace FastGithub.Http
///
///
///
- public override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
+ public override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
if (request.Headers.UserAgent.Contains(userAgent))
{
throw new FastGithubException($"由于{request.RequestUri}实际指向了{nameof(FastGithub)}自身,{nameof(FastGithub)}已中断本次转发");
}
request.Headers.UserAgent.Add(userAgent);
- return base.SendAsync(request, cancellationToken);
+ var response = await base.SendAsync(request, cancellationToken);
+ response.Headers.Server.TryParseAdd(nameof(FastGithub));
+ return response;
}
}
}
\ No newline at end of file
diff --git a/FastGithub.HttpServer/ApplicationBuilderExtensions.cs b/FastGithub.HttpServer/ApplicationBuilderExtensions.cs
index afccc1d..b52daa5 100644
--- a/FastGithub.HttpServer/ApplicationBuilderExtensions.cs
+++ b/FastGithub.HttpServer/ApplicationBuilderExtensions.cs
@@ -9,24 +9,6 @@ namespace FastGithub
///
public static class ApplicationBuilderExtensions
{
- ///
- /// 使用服务头
- ///
- ///
- ///
- ///
- public static IApplicationBuilder UseServerHeader(this IApplicationBuilder app, string serverHeader = nameof(FastGithub))
- {
- return app.Use(next => context =>
- {
- if (context.Response.HasStarted == false)
- {
- context.Response.Headers.Server = serverHeader;
- }
- return next(context);
- });
- }
-
///
/// 使用http代理中间件
///
diff --git a/FastGithub/Startup.cs b/FastGithub/Startup.cs
index 411ef5d..c58df1f 100644
--- a/FastGithub/Startup.cs
+++ b/FastGithub/Startup.cs
@@ -56,13 +56,11 @@ namespace FastGithub
var httpProxyPort = app.ApplicationServices.GetRequiredService>().Value.HttpProxyPort;
app.MapWhen(context => context.Connection.LocalPort == httpProxyPort, appBuilder =>
{
- appBuilder.UseServerHeader();
appBuilder.UseHttpProxy();
});
app.MapWhen(context => context.Connection.LocalPort != httpProxyPort, appBuilder =>
{
- appBuilder.UseServerHeader();
appBuilder.UseRequestLogging();
appBuilder.UseHttpReverseProxy();