|
1 | 1 | using System;
|
2 | 2 | using System.Collections.Generic;
|
3 | 3 | using System.Linq;
|
4 |
| -using System.Net.Http; |
| 4 | +using System.Net.Http; |
5 | 5 | using Microsoft.AspNetCore.Http;
|
6 | 6 | using Ocelot.Configuration;
|
7 | 7 | using Ocelot.DownstreamRouteFinder.UrlMatcher;
|
@@ -58,15 +58,15 @@ public Response<DownstreamRouteHolder> Get(
|
58 | 58 | private static bool RouteIsApplicableToThisRequest(Route route, string httpMethod, string upstreamHost, IHeaderDictionary requestHeaders)
|
59 | 59 | => (route.UpstreamHttpMethod.Count == 0 || RouteHasHttpMethod(route, httpMethod)) &&
|
60 | 60 | (string.IsNullOrEmpty(route.UpstreamHost) || route.UpstreamHost == upstreamHost) &&
|
61 |
| - (route.UpstreamHeaderRoutingOptions?.Enabled() != true || RouteHasRequiredUpstreamHeaders(route, requestHeaders)); |
| 61 | + (route.UpstreamHeaderRoutingOptions?.Enabled() != true || RequiredUpstreamHeadersArePresent(route.UpstreamHeaderRoutingOptions, requestHeaders)); |
62 | 62 |
|
63 | 63 | private static bool RouteHasHttpMethod(Route route, string httpMethod) =>
|
64 | 64 | route.UpstreamHttpMethod.Contains(new HttpMethod(httpMethod));
|
65 | 65 |
|
66 |
| - private static bool RouteHasRequiredUpstreamHeaders(Route route, IHeaderDictionary requestHeaders) => |
67 |
| - route.UpstreamHeaderRoutingOptions.Mode == UpstreamHeaderRoutingTriggerMode.Any |
68 |
| - ? route.UpstreamHeaderRoutingOptions.Headers.HasAnyOf(requestHeaders) |
69 |
| - : route.UpstreamHeaderRoutingOptions.Headers.HasAllOf(requestHeaders); |
| 66 | + private static bool RequiredUpstreamHeadersArePresent(UpstreamHeaderRoutingOptions options, IHeaderDictionary requestHeaders) => |
| 67 | + options.Mode == UpstreamHeaderRoutingTriggerMode.Any |
| 68 | + ? options.Headers.HasAnyOf(requestHeaders) |
| 69 | + : options.Headers.HasAllOf(requestHeaders); |
70 | 70 |
|
71 | 71 | private DownstreamRouteHolder GetPlaceholderNamesAndValues(string path, string query, Route route)
|
72 | 72 | {
|
|
0 commit comments