mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 08:55:28 +08:00 
			
		
		
		
	This commit is contained in:
		@@ -55,16 +55,16 @@ namespace Ocelot.DependencyInjection
 | 
			
		||||
            Services.TryAddSingleton<IInternalConfigurationCreator, FileInternalConfigurationCreator>();
 | 
			
		||||
            Services.TryAddSingleton<IInternalConfigurationRepository, InMemoryInternalConfigurationRepository>();
 | 
			
		||||
            Services.TryAddSingleton<IConfigurationValidator, FileConfigurationFluentValidator>();
 | 
			
		||||
            Services.AddSingleton<HostAndPortValidator>();
 | 
			
		||||
            Services.AddSingleton<IReRoutesCreator, ReRoutesCreator>();
 | 
			
		||||
            Services.AddSingleton<IAggregatesCreator, AggregatesCreator>();
 | 
			
		||||
            Services.AddSingleton<IReRouteKeyCreator, ReRouteKeyCreator>();
 | 
			
		||||
            Services.AddSingleton<IConfigurationCreator, ConfigurationCreator>();
 | 
			
		||||
            Services.AddSingleton<IDynamicsCreator, DynamicsCreator>();
 | 
			
		||||
            Services.AddSingleton<ILoadBalancerOptionsCreator, LoadBalancerOptionsCreator>();
 | 
			
		||||
            Services.AddSingleton<ReRouteFluentValidator>();
 | 
			
		||||
            Services.AddSingleton<FileGlobalConfigurationFluentValidator>();
 | 
			
		||||
            Services.AddSingleton<FileQoSOptionsFluentValidator>();
 | 
			
		||||
            Services.TryAddSingleton<HostAndPortValidator>();
 | 
			
		||||
            Services.TryAddSingleton<IReRoutesCreator, ReRoutesCreator>();
 | 
			
		||||
            Services.TryAddSingleton<IAggregatesCreator, AggregatesCreator>();
 | 
			
		||||
            Services.TryAddSingleton<IReRouteKeyCreator, ReRouteKeyCreator>();
 | 
			
		||||
            Services.TryAddSingleton<IConfigurationCreator, ConfigurationCreator>();
 | 
			
		||||
            Services.TryAddSingleton<IDynamicsCreator, DynamicsCreator>();
 | 
			
		||||
            Services.TryAddSingleton<ILoadBalancerOptionsCreator, LoadBalancerOptionsCreator>();
 | 
			
		||||
            Services.TryAddSingleton<ReRouteFluentValidator>();
 | 
			
		||||
            Services.TryAddSingleton<FileGlobalConfigurationFluentValidator>();
 | 
			
		||||
            Services.TryAddSingleton<FileQoSOptionsFluentValidator>();
 | 
			
		||||
            Services.TryAddSingleton<IClaimsToThingCreator, ClaimsToThingCreator>();
 | 
			
		||||
            Services.TryAddSingleton<IAuthenticationOptionsCreator, AuthenticationOptionsCreator>();
 | 
			
		||||
            Services.TryAddSingleton<IUpstreamTemplatePatternCreator, UpstreamTemplatePatternCreator>();
 | 
			
		||||
@@ -92,8 +92,8 @@ namespace Ocelot.DependencyInjection
 | 
			
		||||
            Services.TryAddSingleton<IUrlPathToUrlTemplateMatcher, RegExUrlMatcher>();
 | 
			
		||||
            Services.TryAddSingleton<IPlaceholderNameAndValueFinder, UrlPathPlaceholderNameAndValueFinder>();
 | 
			
		||||
            Services.TryAddSingleton<IDownstreamPathPlaceholderReplacer, DownstreamTemplatePathPlaceholderReplacer>();
 | 
			
		||||
            Services.AddSingleton<IDownstreamRouteProvider, DownstreamRouteFinder>();
 | 
			
		||||
            Services.AddSingleton<IDownstreamRouteProvider, DownstreamRouteCreator>();
 | 
			
		||||
            Services.TryAddSingleton<IDownstreamRouteProvider, DownstreamRouteFinder>();
 | 
			
		||||
            Services.TryAddSingleton<IDownstreamRouteProvider, DownstreamRouteCreator>();
 | 
			
		||||
            Services.TryAddSingleton<IDownstreamRouteProviderFactory, DownstreamRouteProviderFactory>();
 | 
			
		||||
            Services.TryAddSingleton<IHttpRequester, HttpClientHttpRequester>();
 | 
			
		||||
            Services.TryAddSingleton<IHttpResponder, HttpContextResponder>();
 | 
			
		||||
@@ -114,7 +114,7 @@ namespace Ocelot.DependencyInjection
 | 
			
		||||
            Services.TryAddSingleton<OcelotDiagnosticListener>();
 | 
			
		||||
            Services.TryAddSingleton<IMultiplexer, Multiplexer>();
 | 
			
		||||
            Services.TryAddSingleton<IResponseAggregator, SimpleJsonResponseAggregator>();
 | 
			
		||||
            Services.AddSingleton<ITracingHandlerFactory, TracingHandlerFactory>();
 | 
			
		||||
            Services.TryAddSingleton<ITracingHandlerFactory, TracingHandlerFactory>();
 | 
			
		||||
            Services.TryAddSingleton<IFileConfigurationPollerOptions, InMemoryFileConfigurationPollerOptions>();
 | 
			
		||||
            Services.TryAddSingleton<IAddHeadersToResponse, AddHeadersToResponse>();
 | 
			
		||||
            Services.TryAddSingleton<IPlaceholders, Placeholders>();
 | 
			
		||||
 
 | 
			
		||||
@@ -44,7 +44,7 @@ namespace Ocelot.Responder
 | 
			
		||||
                AddHeaderIfDoesntExist(context, new Header("Content-Length", new []{ response.Content.Headers.ContentLength.ToString() }) );
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            context.Response.StatusCode = (int)response.StatusCode;
 | 
			
		||||
            SetStatusCode(context, (int)response.StatusCode);
 | 
			
		||||
 | 
			
		||||
            context.Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = response.ReasonPhrase;
 | 
			
		||||
 | 
			
		||||
@@ -59,7 +59,15 @@ namespace Ocelot.Responder
 | 
			
		||||
 | 
			
		||||
        public void SetErrorResponseOnContext(HttpContext context, int statusCode)
 | 
			
		||||
        {
 | 
			
		||||
            context.Response.StatusCode = statusCode;
 | 
			
		||||
            SetStatusCode(context, statusCode);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void SetStatusCode(HttpContext context, int statusCode)
 | 
			
		||||
        {
 | 
			
		||||
            if (!context.Response.HasStarted)
 | 
			
		||||
            {
 | 
			
		||||
                context.Response.StatusCode = statusCode;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private static void AddHeaderIfDoesntExist(HttpContext context, Header httpResponseHeader)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user