mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 20:10:50 +08:00 
			
		
		
		
	Merge branch 'develop' of github.com:ThreeMammals/Ocelot into develop
This commit is contained in:
		@@ -39,8 +39,7 @@ namespace Ocelot.Requester
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            catch (TimeoutRejectedException exception)
 | 
					            catch (TimeoutRejectedException exception)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return
 | 
					                return new ErrorResponse<HttpResponseMessage>(new RequestTimedOutError(exception));
 | 
				
			||||||
                    new ErrorResponse<HttpResponseMessage>(new RequestTimedOutError(exception));
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            catch (BrokenCircuitException exception)
 | 
					            catch (BrokenCircuitException exception)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,7 +6,7 @@ namespace Ocelot.Requester
 | 
				
			|||||||
    public class RequestTimedOutError : Error
 | 
					    public class RequestTimedOutError : Error
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public RequestTimedOutError(Exception exception) 
 | 
					        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 class UnableToCompleteRequestError : Error
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public UnableToCompleteRequestError(Exception exception) 
 | 
					        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;
 | 
					                var errors = context.Errors;
 | 
				
			||||||
                _logger.LogError($"{errors.Count} pipeline errors found in {MiddlewareName}. Setting error response status code");
 | 
					                _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);
 | 
					                SetErrorResponse(context.HttpContext, errors);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					            else
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -922,6 +922,55 @@ namespace Ocelot.AcceptanceTests
 | 
				
			|||||||
                .BDDfy();
 | 
					                .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)
 | 
					        private void GivenThereIsAServiceRunningOn(string baseUrl, string basePath, int statusCode, string responseBody)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _builder = new WebHostBuilder()
 | 
					            _builder = new WebHostBuilder()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user