Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit e2e6dcc

Browse files
committed
Merge pull request #2810 from rajansingh10/myfeature
Moving shared default between winHttp & Unix Handler to a seperate common file
2 parents 8def273 + 3c57665 commit e2e6dcc

File tree

6 files changed

+29
-7
lines changed

6 files changed

+29
-7
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
namespace System.Net.Http
5+
{
6+
/// <summary>
7+
/// Defines default values for http handler properties which is meant to be re-used across WinHttp & UnixHttp Handlers
8+
/// </summary>
9+
internal static class HttpHandlerDefaults
10+
{
11+
public const int DefaultMaxAutomaticRedirections = 50;
12+
public const DecompressionMethods DefaultAutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
13+
public const bool DefaultAutomaticRedirection = true;
14+
}
15+
}

src/System.Net.Http.WinHttpHandler/src/System.Net.Http.WinHttpHandler.msbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<CompileItem Include="$(CommonPath)\Interop\Windows\winhttp\Interop.winhttp_types.cs" />
1414
<CompileItem Include="$(CommonPath)\Interop\Windows\winhttp\Interop.winhttp.cs" />
1515
<CompileItem Include="$(CommonPath)\Microsoft\Win32\SafeHandles\SafeHandleZeroOrMinusOneIsInvalid.cs" />
16+
<CompileItem Include="$(CommonPath)\System\Net\Http\HttpHandlerDefaults.cs" />
1617
<CompileItem Include="$(MSBuildThisFileDirectory)\System\Net\Http\CertificateHelper.cs" />
1718
<CompileItem Include="$(MSBuildThisFileDirectory)\System\Net\Http\WinHttpChannelBinding.cs" />
1819
<CompileItem Include="$(MSBuildThisFileDirectory)\System\Net\Http\WinHttpException.cs" />

src/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ public class WinHttpHandler : HttpMessageHandler
107107
private object _lockObject = new object();
108108
private bool _doManualDecompressionCheck = false;
109109
private WinInetProxyHelper _proxyHelper = null;
110-
private bool _automaticRedirection = true;
111-
private int _maxAutomaticRedirections = 50;
112-
private DecompressionMethods _automaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
110+
private bool _automaticRedirection = HttpHandlerDefaults.DefaultAutomaticRedirection;
111+
private int _maxAutomaticRedirections = HttpHandlerDefaults.DefaultMaxAutomaticRedirections;
112+
private DecompressionMethods _automaticDecompression = HttpHandlerDefaults.DefaultAutomaticDecompression;
113113
private CookieUsePolicy _cookieUsePolicy = CookieUsePolicy.UseInternalCookieStoreOnly;
114114
private CookieContainer _cookieContainer = null;
115115

src/System.Net.Http.WinHttpHandler/tests/UnitTests/System.Net.Http.WinHttpHandler.Unit.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
<Compile Include="$(CommonPath)\Microsoft\Win32\SafeHandles\SafeHandleZeroOrMinusOneIsInvalid.cs">
3838
<Link>Common\Microsoft\Win32\SafeHandles\SafeHandleZeroOrMinusOneIsInvalid.cs</Link>
3939
</Compile>
40+
<Compile Include="$(CommonPath)\System\Net\Http\HttpHandlerDefaults.cs">
41+
<Link>Common\System\Net\Http\HttpHandlerDefaults.cs</Link>
42+
</Compile>
4043
<Compile Include="..\..\src\System\Net\Http\CertificateHelper.cs">
4144
<Link>ProductionCode\CertificateHelper.cs</Link>
4245
</Compile>

src/System.Net.Http/src/System.Net.Http.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@
182182
</Compile>
183183
<Compile Include="$(CommonPath)\System\NotImplemented.cs">
184184
<Link>Common\System\NotImplemented.cs</Link>
185-
</Compile>
185+
</Compile>
186+
<Compile Include="$(CommonPath)\System\Net\Http\HttpHandlerDefaults.cs">
187+
<Link>Common\System\Net\Http\HttpHandlerDefaults.cs</Link>
188+
</Compile>
186189
</ItemGroup>
187190
<ItemGroup>
188191
<None Include="project.json" />

src/System.Net.Http/src/System/Net/Http/Unix/CurlHandler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ internal partial class CurlHandler : HttpMessageHandler
5757
private IWebProxy _proxy = null;
5858
private ICredentials _serverCredentials = null;
5959
private ProxyUsePolicy _proxyPolicy = ProxyUsePolicy.UseDefaultProxy;
60-
private DecompressionMethods _automaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
60+
private DecompressionMethods _automaticDecompression = HttpHandlerDefaults.DefaultAutomaticDecompression;
6161
private SafeCurlMultiHandle _multiHandle;
6262
private GCHandle _multiHandlePtr = new GCHandle();
6363
private bool _preAuthenticate = false;
6464
private CredentialCache _credentialCache = null;
6565
private CookieContainer _cookieContainer = null;
6666
private bool _useCookie = false;
67-
private bool _automaticRedirection = true;
68-
private int _maxAutomaticRedirections = 50;
67+
private bool _automaticRedirection = HttpHandlerDefaults.DefaultAutomaticRedirection;
68+
private int _maxAutomaticRedirections = HttpHandlerDefaults.DefaultMaxAutomaticRedirections;
6969

7070
#endregion
7171

0 commit comments

Comments
 (0)