-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add EnableMultipleHttp2Connections property to HttpHandlerOptions
#2126
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
base: develop
Are you sure you want to change the base?
Changes from 4 commits
f760b11
8b92cd0
5921a9c
3efc97c
11e1a84
33cf5fb
7541cbf
0013c4a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,8 @@ public HttpHandlerOptions Create(FileHttpHandlerOptions options) | |
| var pooledConnectionLifetime = TimeSpan.FromSeconds(options.PooledConnectionLifetimeSeconds ?? DefaultPooledConnectionLifetimeSeconds); | ||
|
|
||
| return new HttpHandlerOptions(options.AllowAutoRedirect, | ||
| options.UseCookieContainer, useTracing, options.UseProxy, maxConnectionPerServer, pooledConnectionLifetime); | ||
| options.UseCookieContainer, useTracing, options.UseProxy, maxConnectionPerServer, pooledConnectionLifetime, | ||
| options.EnableMultipleHttp2Connections); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Certainly, extending the default advanced initialization constructor with all initialization values is beneficial. However, it's also worth considering the introduction of a copy constructor. Having the copy-constructor we can write: return new HttpHandlerOptions(options);
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @raman-m |
||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,14 +6,15 @@ | |
| public class HttpHandlerOptions | ||
| { | ||
| public HttpHandlerOptions(bool allowAutoRedirect, bool useCookieContainer, bool useTracing, bool useProxy, | ||
| int maxConnectionsPerServer, TimeSpan pooledConnectionLifeTime) | ||
| int maxConnectionsPerServer, TimeSpan pooledConnectionLifeTime, bool enableMultipleHttp2Connections) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lack of copy-constructor. |
||
| { | ||
| AllowAutoRedirect = allowAutoRedirect; | ||
| UseCookieContainer = useCookieContainer; | ||
| UseTracing = useTracing; | ||
| UseProxy = useProxy; | ||
| MaxConnectionsPerServer = maxConnectionsPerServer; | ||
| PooledConnectionLifeTime = pooledConnectionLifeTime; | ||
| EnableMultipleHttp2Connections = enableMultipleHttp2Connections; | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -51,5 +52,11 @@ public HttpHandlerOptions(bool allowAutoRedirect, bool useCookieContainer, bool | |
| /// </summary> | ||
| /// <value>PooledConnectionLifeTime.</value> | ||
| public TimeSpan PooledConnectionLifeTime { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets a value that indicates whether additional HTTP/2 connections can be established to the same server. | ||
| /// </summary> | ||
| /// <value>EnableMultipleHttp2Connections.</value> | ||
| public bool EnableMultipleHttp2Connections { get; } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ public DownstreamRouteExtensionsTests() | |
| new List<DownstreamHostAndPort>(), | ||
| null, | ||
| null, | ||
| new HttpHandlerOptions(false, false, false, false, 0, TimeSpan.Zero), | ||
| new HttpHandlerOptions(false, false, false, false, 0, TimeSpan.Zero, false), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not to define default constructor with default initialization values including a value for |
||
| default, | ||
| default, | ||
| new QoSOptions(0, 0, 0, null), | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -33,7 +33,7 @@ public void should_not_use_tracing_if_fake_tracer_registered() | |||
| }, | ||||
| }; | ||||
|
|
||||
| var expectedOptions = new HttpHandlerOptions(false, false, false, true, int.MaxValue, DefaultPooledConnectionLifeTime); | ||||
| var expectedOptions = new HttpHandlerOptions(false, false, false, true, int.MaxValue, DefaultPooledConnectionLifeTime, false); | ||||
|
|
||||
| this.Given(x => GivenTheFollowing(fileRoute)) | ||||
| .When(x => WhenICreateHttpHandlerOptions()) | ||||
|
|
@@ -52,7 +52,7 @@ public void should_use_tracing_if_real_tracer_registered() | |||
| }, | ||||
| }; | ||||
|
|
||||
| var expectedOptions = new HttpHandlerOptions(false, false, true, true, int.MaxValue, DefaultPooledConnectionLifeTime); | ||||
| var expectedOptions = new HttpHandlerOptions(false, false, true, true, int.MaxValue, DefaultPooledConnectionLifeTime, false); | ||||
|
|
||||
| this.Given(x => GivenTheFollowing(fileRoute)) | ||||
| .And(x => GivenARealTracer()) | ||||
|
|
@@ -65,7 +65,7 @@ public void should_use_tracing_if_real_tracer_registered() | |||
| public void should_create_options_with_useCookie_false_and_allowAutoRedirect_true_as_default() | ||||
| { | ||||
| var fileRoute = new FileRoute(); | ||||
| var expectedOptions = new HttpHandlerOptions(false, false, false, true, int.MaxValue, DefaultPooledConnectionLifeTime); | ||||
| var expectedOptions = new HttpHandlerOptions(false, false, false, true, int.MaxValue, DefaultPooledConnectionLifeTime, false); | ||||
|
|
||||
| this.Given(x => GivenTheFollowing(fileRoute)) | ||||
| .When(x => WhenICreateHttpHandlerOptions()) | ||||
|
|
@@ -86,7 +86,7 @@ public void should_create_options_with_specified_useCookie_and_allowAutoRedirect | |||
| }, | ||||
| }; | ||||
|
|
||||
| var expectedOptions = new HttpHandlerOptions(false, false, false, true, int.MaxValue, DefaultPooledConnectionLifeTime); | ||||
| var expectedOptions = new HttpHandlerOptions(false, false, false, true, int.MaxValue, DefaultPooledConnectionLifeTime, false); | ||||
|
|
||||
| this.Given(x => GivenTheFollowing(fileRoute)) | ||||
| .When(x => WhenICreateHttpHandlerOptions()) | ||||
|
|
@@ -102,7 +102,7 @@ public void should_create_options_with_useproxy_true_as_default() | |||
| HttpHandlerOptions = new FileHttpHandlerOptions(), | ||||
| }; | ||||
|
|
||||
| var expectedOptions = new HttpHandlerOptions(false, false, false, true, int.MaxValue, DefaultPooledConnectionLifeTime); | ||||
| var expectedOptions = new HttpHandlerOptions(false, false, false, true, int.MaxValue, DefaultPooledConnectionLifeTime, false); | ||||
|
|
||||
| this.Given(x => GivenTheFollowing(fileRoute)) | ||||
| .When(x => WhenICreateHttpHandlerOptions()) | ||||
|
|
@@ -121,7 +121,7 @@ public void should_create_options_with_specified_useproxy() | |||
| }, | ||||
| }; | ||||
|
|
||||
| var expectedOptions = new HttpHandlerOptions(false, false, false, false, int.MaxValue, DefaultPooledConnectionLifeTime); | ||||
| var expectedOptions = new HttpHandlerOptions(false, false, false, false, int.MaxValue, DefaultPooledConnectionLifeTime, false); | ||||
|
|
||||
| this.Given(x => GivenTheFollowing(fileRoute)) | ||||
| .When(x => WhenICreateHttpHandlerOptions()) | ||||
|
|
@@ -140,7 +140,7 @@ public void should_create_options_with_specified_MaxConnectionsPerServer() | |||
| }, | ||||
| }; | ||||
|
|
||||
| var expectedOptions = new HttpHandlerOptions(false, false, false, true, 10, DefaultPooledConnectionLifeTime); | ||||
| var expectedOptions = new HttpHandlerOptions(false, false, false, true, 10, DefaultPooledConnectionLifeTime, false); | ||||
|
|
||||
| this.Given(x => GivenTheFollowing(fileRoute)) | ||||
| .When(x => WhenICreateHttpHandlerOptions()) | ||||
|
|
@@ -159,7 +159,7 @@ public void should_create_options_fixing_specified_MaxConnectionsPerServer_range | |||
| }, | ||||
| }; | ||||
|
|
||||
| var expectedOptions = new HttpHandlerOptions(false, false, false, true, int.MaxValue, DefaultPooledConnectionLifeTime); | ||||
| var expectedOptions = new HttpHandlerOptions(false, false, false, true, int.MaxValue, DefaultPooledConnectionLifeTime, false); | ||||
|
|
||||
| this.Given(x => GivenTheFollowing(fileRoute)) | ||||
| .When(x => WhenICreateHttpHandlerOptions()) | ||||
|
|
@@ -178,7 +178,26 @@ public void should_create_options_fixing_specified_MaxConnectionsPerServer_range | |||
| }, | ||||
| }; | ||||
|
|
||||
| var expectedOptions = new HttpHandlerOptions(false, false, false, true, int.MaxValue, DefaultPooledConnectionLifeTime); | ||||
| var expectedOptions = new HttpHandlerOptions(false, false, false, true, int.MaxValue, DefaultPooledConnectionLifeTime, false); | ||||
|
|
||||
| this.Given(x => GivenTheFollowing(fileRoute)) | ||||
| .When(x => WhenICreateHttpHandlerOptions()) | ||||
| .Then(x => ThenTheFollowingOptionsReturned(expectedOptions)) | ||||
| .BDDfy(); | ||||
| } | ||||
|
|
||||
| [Fact] | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lack of
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not understand what you mean
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean this
|
||||
| public void should_create_options_with_enableMultipleHttp2Connections() | ||||
| { | ||||
| var fileRoute = new FileRoute | ||||
| { | ||||
| HttpHandlerOptions = new FileHttpHandlerOptions | ||||
| { | ||||
| EnableMultipleHttp2Connections = true, | ||||
| }, | ||||
| }; | ||||
|
|
||||
| var expectedOptions = new HttpHandlerOptions(false, false, false, true, int.MaxValue, DefaultPooledConnectionLifeTime, true); | ||||
|
|
||||
| this.Given(x => GivenTheFollowing(fileRoute)) | ||||
| .When(x => WhenICreateHttpHandlerOptions()) | ||||
|
|
@@ -204,6 +223,7 @@ private void ThenTheFollowingOptionsReturned(HttpHandlerOptions expected) | |||
| _httpHandlerOptions.UseTracing.ShouldBe(expected.UseTracing); | ||||
| _httpHandlerOptions.UseProxy.ShouldBe(expected.UseProxy); | ||||
| _httpHandlerOptions.MaxConnectionsPerServer.ShouldBe(expected.MaxConnectionsPerServer); | ||||
| _httpHandlerOptions.EnableMultipleHttp2Connections.ShouldBe(expected.EnableMultipleHttp2Connections); | ||||
| } | ||||
|
|
||||
| private void GivenARealTracer() | ||||
|
|
||||
Uh oh!
There was an error while loading. Please reload this page.