mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 08:55:28 +08:00 
			
		
		
		
	@@ -39,8 +39,7 @@ namespace Ocelot.Requester
 | 
			
		||||
            }
 | 
			
		||||
            catch (TimeoutRejectedException exception)
 | 
			
		||||
            {
 | 
			
		||||
                return
 | 
			
		||||
                    new ErrorResponse<HttpResponseMessage>(new RequestTimedOutError(exception));
 | 
			
		||||
                return new ErrorResponse<HttpResponseMessage>(new RequestTimedOutError(exception));
 | 
			
		||||
            }
 | 
			
		||||
            catch (BrokenCircuitException exception)
 | 
			
		||||
            {
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,7 @@ namespace Ocelot.Requester
 | 
			
		||||
    public class RequestTimedOutError : Error
 | 
			
		||||
    {
 | 
			
		||||
        public RequestTimedOutError(Exception exception) 
 | 
			
		||||
            : base($"Timeout making http request, exception: {exception.Message}", OcelotErrorCode.RequestTimedOutError)
 | 
			
		||||
            : base($"Timeout making http request, exception: {exception}", OcelotErrorCode.RequestTimedOutError)
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,7 @@ namespace Ocelot.Requester
 | 
			
		||||
    public class UnableToCompleteRequestError : Error
 | 
			
		||||
    {
 | 
			
		||||
        public UnableToCompleteRequestError(Exception exception) 
 | 
			
		||||
            : base($"Error making http request, exception: {exception.Message}", OcelotErrorCode.UnableToCompleteRequestError)
 | 
			
		||||
            : base($"Error making http request, exception: {exception}", OcelotErrorCode.UnableToCompleteRequestError)
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -39,6 +39,12 @@ namespace Ocelot.Responder.Middleware
 | 
			
		||||
            {
 | 
			
		||||
                var errors = context.Errors;
 | 
			
		||||
                _logger.LogError($"{errors.Count} pipeline errors found in {MiddlewareName}. Setting error response status code");
 | 
			
		||||
 | 
			
		||||
                foreach(var error in errors)
 | 
			
		||||
                {
 | 
			
		||||
                    _logger.LogError(error.Message);
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
                SetErrorResponse(context.HttpContext, errors);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
 
 | 
			
		||||
@@ -922,6 +922,55 @@ namespace Ocelot.AcceptanceTests
 | 
			
		||||
                .BDDfy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Fact]
 | 
			
		||||
        public void should_fix_issue_271()
 | 
			
		||||
        {
 | 
			
		||||
            var configuration = new FileConfiguration
 | 
			
		||||
            {
 | 
			
		||||
                ReRoutes = new List<FileReRoute>
 | 
			
		||||
                    {
 | 
			
		||||
                        new FileReRoute
 | 
			
		||||
                        {
 | 
			
		||||
                            DownstreamPathTemplate = "/api/v1/{everything}",
 | 
			
		||||
                            DownstreamScheme = "http",
 | 
			
		||||
                            UpstreamPathTemplate = "/api/v1/{everything}",
 | 
			
		||||
                            UpstreamHttpMethod = new List<string> { "Get", "Put", "Post" },
 | 
			
		||||
                            DownstreamHostAndPorts = new List<FileHostAndPort>
 | 
			
		||||
                            {
 | 
			
		||||
                                new FileHostAndPort
 | 
			
		||||
                                {
 | 
			
		||||
                                    Host = "localhost",
 | 
			
		||||
                                    Port = 54879,
 | 
			
		||||
                                }
 | 
			
		||||
                            },
 | 
			
		||||
                        },
 | 
			
		||||
                        new FileReRoute
 | 
			
		||||
                        {
 | 
			
		||||
                            DownstreamPathTemplate = "/connect/token",
 | 
			
		||||
                            DownstreamScheme = "http",
 | 
			
		||||
                            UpstreamPathTemplate = "/connect/token",
 | 
			
		||||
                            UpstreamHttpMethod = new List<string> { "Post" },
 | 
			
		||||
                            DownstreamHostAndPorts = new List<FileHostAndPort>
 | 
			
		||||
                            {
 | 
			
		||||
                                new FileHostAndPort
 | 
			
		||||
                                {
 | 
			
		||||
                                    Host = "localhost",
 | 
			
		||||
                                    Port = 5001,
 | 
			
		||||
                                }
 | 
			
		||||
                            },
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:54879/", "/api/v1/modules/Test", 200, "Hello from Laura"))
 | 
			
		||||
                .And(x => _steps.GivenThereIsAConfiguration(configuration))
 | 
			
		||||
                .And(x => _steps.GivenOcelotIsRunning())
 | 
			
		||||
                .When(x => _steps.WhenIGetUrlOnTheApiGateway("/api/v1/modules/Test"))
 | 
			
		||||
                .Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
 | 
			
		||||
                .And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Laura"))
 | 
			
		||||
                .BDDfy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void GivenThereIsAServiceRunningOn(string baseUrl, string basePath, int statusCode, string responseBody)
 | 
			
		||||
        {
 | 
			
		||||
            _builder = new WebHostBuilder()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user