-
Notifications
You must be signed in to change notification settings - Fork 835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuration of the proxied HTTP request version. #512
Configuration of the proxied HTTP request version. #512
Conversation
test/ReverseProxy.Tests/Middleware/ProxyInvokerMiddlewareTests.cs
Outdated
Show resolved
Hide resolved
test/ReverseProxy.Tests/Middleware/ProxyInvokerMiddlewareTests.cs
Outdated
Show resolved
Hide resolved
|
||
namespace Microsoft.ReverseProxy.RuntimeModel | ||
{ | ||
public readonly struct ClusterProxyHttpRequestOptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed offline: we'll want to see how we can unify this with RequestProxyOptions so we don't have to allocate that per request. The big differences are:
- RequestProxyOptions has Transforms on it which come from routeConfig.
- RequestProxyOptions has the Timeout which should be easy to move/mirror.
- struct vs class, readonly vs mutable
- Naming
Some possibilities:
- We come up with a type that works in both scenarios and use that on ClusterConfig.
- RequestProxyOptions becomes a readonly struct so at least we don't have to allocate it. We'd still end up copying the paramters across.
- Transforms get passed into IHttpProxy.ProxyAsync as a separate parameter, making the options types more compatible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/ReverseProxy/Abstractions/ClusterDiscovery/Contract/ProxyHttpRequestOptions.cs
Show resolved
Hide resolved
src/ReverseProxy/Abstractions/ClusterDiscovery/Contract/ProxyHttpRequestOptions.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider applying the request version settings to active health probes.
@@ -31,7 +31,7 @@ public void CreateRequest_HealthEndpointIsNotDefined_UseDestinationAddress(strin | |||
private ClusterConfig GetClusterConfig(string id, ClusterActiveHealthCheckOptions healthCheckOptions) | |||
{ | |||
return new ClusterConfig( | |||
new Cluster { Id = id }, new ClusterHealthCheckOptions(default, healthCheckOptions), default, default, null, default, null); | |||
new Cluster { Id = id }, new ClusterHealthCheckOptions(default, healthCheckOptions), default, default, null, default, default, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the request version settings are also applied to active health probes, it must be verified in this test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Production code looks good now, only a couple test-related suggestions.
test/ReverseProxy.Tests/Service/HealthChecks/DefaultProbingRequestFactoryTests.cs
Outdated
Show resolved
Hide resolved
test/ReverseProxy.Tests/Service/HealthChecks/DefaultProbingRequestFactoryTests.cs
Outdated
Show resolved
Hide resolved
src/ReverseProxy/Abstractions/ClusterDiscovery/Contract/ProxyHttpRequestOptions.cs
Outdated
Show resolved
Hide resolved
src/ReverseProxy/Service/HealthChecks/DefaultProbingRequestFactory.cs
Outdated
Show resolved
Hide resolved
aca9b23
to
dc10c82
Compare
@Tratcher, @alnikola: I think I've addressed all comments except for the type-merging one, which I'd rather do separately if you're OK with it. I'll file an issue and look into it immediately. I'd just prefer to split the work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File an issue for the type merging.
|
||
Configuration settings: | ||
- RequestTimeout - the timeout for the outgoing request sent by [HttpMessageInvoker.SendAsync](https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpmessageinvoker.sendasync?view=netcore-3.1). If not specified, 100 seconds is used. | ||
- Version - outgoing request [version](https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httprequestmessage.version?view=netcore-3.1). The supported values at the moment are 1.0, 1.1 and 2. Default value is 2. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Version - outgoing request [version](https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httprequestmessage.version?view=netcore-3.1). The supported values at the moment are 1.0, 1.1 and 2. Default value is 2. | |
- Version - outgoing request [version](https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httprequestmessage.version?view=netcore-3.1). The supported values at the moment are `1.0`, `1.1` and `2`. Default value is `2`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/ReverseProxy/Abstractions/ClusterDiscovery/Contract/ProxyHttpRequestOptions.cs
Show resolved
Hide resolved
src/ReverseProxy/Service/RuntimeModel/ClusterProxyHttpRequestOptions.cs
Outdated
Show resolved
Hide resolved
#else | ||
public ClusterProxyHttpRequestOptions(TimeSpan? requestTimeout, Version version) | ||
{ | ||
RequestTimeout = requestTimeout; | ||
Version = version; | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This constructor should exist in both versions. We don't change/remove public API across versions if we can avoid it.
#else | |
public ClusterProxyHttpRequestOptions(TimeSpan? requestTimeout, Version version) | |
{ | |
RequestTimeout = requestTimeout; | |
Version = version; | |
} | |
#endif | |
#endif | |
public ClusterProxyHttpRequestOptions(TimeSpan? requestTimeout, Version version) | |
{ | |
RequestTimeout = requestTimeout; | |
Version = version; | |
} | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@alnikola : could you please give this another look? I cannot merge till you approve since you originally requested changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
RequestTimeout = requestTimeout; | ||
Version = version; | ||
#if NET | ||
VersionPolicy = HttpVersionPolicy.RequestVersionOrLower; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VersionPolicy = null;
The default is applied later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aaaa, you're right.
Adds configuration side to setting up
Version
andVersioningPolicy
(for .NET 5 and higher) of an outbound HTTP Request.Fixes #282