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

Commit 756ed11

Browse files
committed
Moving shared default between winHttp & Unix Handler to a seperate common file
1 parent d22fe16 commit 756ed11

File tree

6 files changed

+28
-6
lines changed

6 files changed

+28
-6
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@
109109
<Compile Include="$(CommonPath)\System\Net\Logging.cs">
110110
<Link>Common\System\Net\Logging.cs</Link>
111111
</Compile>
112+
<Compile Include="$(CommonPath)\System\Net\Http\HttpHandlerDefaults.cs">
113+
<Link>Common\System\Net\Http\HttpHandlerDefaults.cs</Link>
114+
</Compile>
112115
</ItemGroup>
113116

114117
<ItemGroup Condition=" '$(TargetsWindows)' == 'true' ">

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
@@ -55,13 +55,13 @@ internal partial class CurlHandler : HttpMessageHandler
5555
private IWebProxy _proxy = null;
5656
private ICredentials _serverCredentials = null;
5757
private ProxyUsePolicy _proxyPolicy = ProxyUsePolicy.UseDefaultProxy;
58-
private DecompressionMethods _automaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
58+
private DecompressionMethods _automaticDecompression = HttpHandlerDefaults.DefaultAutomaticDecompression;
5959
private SafeCurlMultiHandle _multiHandle;
6060
private GCHandle _multiHandlePtr = new GCHandle();
6161
private CookieContainer _cookieContainer = null;
6262
private bool _useCookie = false;
63-
private bool _automaticRedirection = true;
64-
private int _maxAutomaticRedirections = 50;
63+
private bool _automaticRedirection = HttpHandlerDefaults.DefaultAutomaticRedirection;
64+
private int _maxAutomaticRedirections = HttpHandlerDefaults.DefaultMaxAutomaticRedirections;
6565

6666
#endregion
6767

0 commit comments

Comments
 (0)