Skip to content

Obsolete HttpWebRequestConnection on .NET Core #3391

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

Merged
merged 11 commits into from
Sep 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ indent_size = 4
indent_style = space
indent_size = 4

[*.{md,markdown,json,js,csproj,fsproj,targets}]
[*.{md,markdown,json,js,csproj,fsproj,targets,targets,props}]
indent_style = space
indent_size = 2

Expand Down
6 changes: 6 additions & 0 deletions build/scripts/scripts.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
<None Include="Commandline.fsx" />
<None Include="Targets.fsx" />
</ItemGroup>
<ItemGroup>
<Content Include="..\..\paket.bat"><Link>paket.bat</Link></Content>
<Content Include="..\..\paket.dependencies"><Link>paket.bat</Link></Content>
<Content Include="..\..\build.sh"><Link>paket.bat</Link></Content>
<Content Include="..\..\build.bat"><Link>paket.bat</Link></Content>
</ItemGroup>
<PropertyGroup>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
</PropertyGroup>
Expand Down
11 changes: 11 additions & 0 deletions src/Artifacts.build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.bat))\src\Library.build.props" />
<!--
Sets up the properties for assemblies we want to publish to a separate output folder (outside of src) during our build process.
e.g ApiGenerator we'd like to keep private but we do want to publish it to build/_output during our FAKE build
-->
<PropertyGroup>
<OutputPath Condition="'$(OutputPathBaseDir)' != ''">$(OutputPathBaseDir)\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/CodeGeneration/ApiGenerator/ApiGenerator.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.bat))\src\Artifacts.build.props" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
Expand All @@ -17,5 +18,4 @@
<PackageReference Include="RazorLight.Unofficial" Version="2.0.0-beta1.1" />
<!--<PackageReference Include="RazorLight" Version="2.0.0-beta1" />-->
</ItemGroup>
<Import Project="..\..\outputpath.props" />
</Project>
23 changes: 19 additions & 4 deletions src/CodeGeneration/DocGenerator/Buildalyzer/ProjectAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ public Project Load()
}
}



// Tweaks the project file a bit to ensure a succesfull build
private static XDocument TweakProjectDocument(XDocument projectDocument, string projectFolder)
{
Expand All @@ -128,10 +130,12 @@ private static XDocument TweakProjectDocument(XDocument projectDocument, string
if (att == null) continue;

var project = att.Value;
if (project.EndsWith("Clients.Common.targets"))
att.Value = Path.GetFullPath(Path.Combine(projectFolder, att.Value));
else if (project.EndsWith("outputpath.props"))
att.Value = Path.GetFullPath(Path.Combine(projectFolder, att.Value));

if (!ResolveKnownPropsPath(projectFolder, project, att, "PublishArtifacts.build.props"))
{
ResolveKnownPropsPath(projectFolder, project, att, "Artifacts.build.props");
}
ResolveKnownPropsPath(projectFolder, project, att, "Library.build.props");
}
// Add SkipGetTargetFrameworkProperties to every ProjectReference
foreach (XElement projectReference in projectDocument.GetDescendants("ProjectReference").ToArray())
Expand All @@ -149,6 +153,17 @@ private static XDocument TweakProjectDocument(XDocument projectDocument, string
return projectDocument;
}

private static bool ResolveKnownPropsPath(string projectFolder, string project, XAttribute att, string buildPropFile)
{
if (!project.Contains(buildPropFile)) return false;
var dir = new DirectoryInfo(projectFolder).Parent;
while (dir != null && dir.Name != "src")
dir = dir.Parent;
if (dir == null) return true;
att.Value = Path.GetFullPath(Path.Combine(dir.FullName, buildPropFile));
return false;
}

private ProjectCollection CreateProjectCollection()
{
ProjectCollection projectCollection = new ProjectCollection(_globalProperties);
Expand Down
2 changes: 1 addition & 1 deletion src/CodeGeneration/DocGenerator/DocGenerator.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.bat))\src\Artifacts.build.props" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
Expand All @@ -17,5 +18,4 @@
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="2.3.2" />
<PackageReference Include="NuDoq" Version="1.2.5" />
</ItemGroup>
<Import Project="..\..\outputpath.props" />
</Project>
24 changes: 1 addition & 23 deletions src/Directory.build.props
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
<Project>
<PropertyGroup>
<!-- Default Version numbers -->
<CurrentVersion>6.0.0</CurrentVersion>
<CurrentAssemblyVersion>6.0.0</CurrentAssemblyVersion>
<CurrentAssemblyFileVersion>6.0.0</CurrentAssemblyFileVersion>
<!-- Version and Informational reflect actual version -->
<Version>$(CurrentVersion)</Version>
<InformationalVersion>$(CurrentVersion)</InformationalVersion>
<!-- Assembly version is sticky to MAJOR.0.0.0 to avoid binding redirects because we strong name our assemblies -->
<AssemblyVersion>$(CurrentAssemblyVersion)</AssemblyVersion>
<!-- File version reflects actual version number without prelease since that not allowed in its struct -->
<FileVersion>$(CurrentAssemblyFileVersion)</FileVersion>

<DefineConstants Condition="'$(TargetFramework)'=='netstandard2.0'">$(DefineConstants);DOTNETCORE</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)'=='netcoreapp2.0'">$(DefineConstants);DOTNETCORE</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)'=='netcoreapp2.1'">$(DefineConstants);DOTNETCORE</DefineConstants>

<RepoUri>https://raw.githubusercontent.com/elastic/elasticsearch-net</RepoUri>
<Authors>Elasticsearch BV</Authors>
<Copyright>Elasticsearch BV</Copyright>
<PackageProjectUrl>https://github.com/elastic/elasticsearch-net</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/elastic/elasticsearch-net/blob/master/license.txt</PackageLicenseUrl>
<ReleaseNotes>See https://github.com/elastic/elasticsearch-net/releases</ReleaseNotes>
<PackageIconUrl>https://raw.githubusercontent.com/elastic/elasticsearch-net/master/build/nuget-icon.png</PackageIconUrl>
<LangVersion>Latest</LangVersion>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Elasticsearch.Net/Connection/CertificateValidations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static Func<object, X509Certificate, X509Chain, SslPolicyErrors, bool> Au

private static X509Certificate2 to2(X509Certificate certificate)
{
#if !FEATURE_HTTPWEBREQUEST
#if DOTNETCORE
return new X509Certificate2(certificate.Export(X509ContentType.Cert));
#else
return new X509Certificate2(certificate);
Expand Down
4 changes: 2 additions & 2 deletions src/Elasticsearch.Net/Connection/ClientCertificate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ THE SOFTWARE.

namespace Elasticsearch.Net
{
//.NET removed the setter for PrivateKey for X509Certificate, you'll have to manually convert to pfx/p12 or add the key to the machine store
#if FEATURE_HTTPWEBREQUEST
//.NET core removed the setter for PrivateKey for X509Certificate, you'll have to manually convert to pfx/p12 or add the key to the machine store
#if !DOTNETCORE

public class ClientCertificate
{
Expand Down
4 changes: 3 additions & 1 deletion src/Elasticsearch.Net/Connection/HttpConnection-CoreFx.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !FEATURE_HTTPWEBREQUEST
#if DOTNETCORE
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
Expand Down Expand Up @@ -29,6 +29,8 @@ internal class WebProxy : IWebProxy
public bool IsBypassed(Uri host) => host.IsLoopback;
}


/// <summary> The default IConnection implementation. Uses <see cref="HttpClient"/>.</summary>
public class HttpConnection : IConnection
{
private readonly object _lock = new object();
Expand Down
16 changes: 3 additions & 13 deletions src/Elasticsearch.Net/Connection/HttpConnection.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
#if FEATURE_HTTPWEBREQUEST
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
#if !DOTNETCORE
using System.Net;
using System.Net.Security;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Elasticsearch.Net
{
public class HttpConnection : HttpWebRequestConnection
{
}
/// <summary> The default IConnection implementation. Uses <see cref="HttpWebRequest"/> on the current .NET desktop framework.</summary>
public class HttpConnection : HttpWebRequestConnection { }
}
#endif
5 changes: 4 additions & 1 deletion src/Elasticsearch.Net/Connection/HttpWebRequestConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

namespace Elasticsearch.Net
{
#if DOTNETCORE
[Obsolete("CoreFX HttpWebRequest uses HttpClient under the covers but does not reuse HttpClient instances, we'll therefor stop shipping with this class in the next major version")]
#endif
public class HttpWebRequestConnection : IConnection
{
internal static bool IsMono { get; } = Type.GetType("Mono.Runtime") != null;
Expand Down Expand Up @@ -57,7 +60,7 @@ protected virtual HttpWebRequest CreateWebRequest(RequestData requestData)

request.Accept = requestData.Accept;
request.ContentType = requestData.RequestMimeType;
#if FEATURE_HTTPWEBREQUEST
#if !DOTNETCORE
// on netstandard/netcoreapp2.0 this throws argument exception
request.MaximumResponseHeadersLength = -1;
#endif
Expand Down
3 changes: 1 addition & 2 deletions src/Elasticsearch.Net/Elasticsearch.Net.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\build\Clients.Common.targets" />
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.bat))\src\PublishArtifacts.build.props" />
<PropertyGroup>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard2.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
</ItemGroup>
<Import Project="..\outputpath.props" />
</Project>
4 changes: 2 additions & 2 deletions src/Elasticsearch.Net/Transport/Transport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Threading;
using System;
using System.Linq;
#if FEATURE_HTTPWEBREQUEST
#if !DOTNETCORE
using System.Net;
#endif

Expand Down Expand Up @@ -203,7 +203,7 @@ private void HandleElasticsearchClientException(RequestData data, Exception clie
//This causes it to behave differently to .NET FULL. We already wrapped the WebExeption
//under ElasticsearchServerException and it exposes way more information as part of it's
//exception message e.g the the root cause of the server error body.
#if FEATURE_HTTPWEBREQUEST
#if !DOTNETCORE
if (a.OriginalException is WebException)
a.OriginalException = clientException;
#endif
Expand Down
51 changes: 31 additions & 20 deletions src/Elasticsearch.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2003
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Build", "_Build", "{432D5575-2347-4D3C-BF8C-3E38410C46CA}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "RelatedFiles", "RelatedFiles", "{432D5575-2347-4D3C-BF8C-3E38410C46CA}"
ProjectSection(SolutionItems) = preProject
..\.editorconfig = ..\.editorconfig
..\.gitignore = ..\.gitignore
..\.travis.yml = ..\.travis.yml
..\appveyor.yml = ..\appveyor.yml
..\build.bat = ..\build.bat
..\build.sh = ..\build.sh
..\build\Clients.Common.targets = ..\build\Clients.Common.targets
..\contributing.md = ..\contributing.md
..\build\Elasticsearch.Net.nuspec = ..\build\Elasticsearch.Net.nuspec
..\global.json = ..\global.json
..\license.txt = ..\license.txt
..\build\NEST.JsonNetSerializer.nuspec = ..\build\NEST.JsonNetSerializer.nuspec
..\build\NEST.nuspec = ..\build\NEST.nuspec
..\NuGet.config = ..\NuGet.config
..\paket.bat = ..\paket.bat
..\paket.dependencies = ..\paket.dependencies
..\readme.md = ..\readme.md
outputpath.props = outputpath.props
..\src\PublishArtifacts.build.props = ..\src\PublishArtifacts.build.props
..\src\Artifacts.build.props = ..\src\Artifacts.build.props
..\src\Library.build.props = ..\src\Library.build.props
Directory.build.props = Directory.build.props
EndProjectSection
EndProject
Expand Down Expand Up @@ -65,6 +50,30 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.Reproduce", "Tests\Te
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.ScratchPad", "Tests\Tests.ScratchPad\Tests.ScratchPad.csproj", "{CE7AC1D4-15AF-47FB-83FA-F7137DFD9076}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Root", "Root", "{EAE89579-CCA9-45CE-AF83-3DCD98690EA8}"
ProjectSection(SolutionItems) = preProject
..\.editorconfig = ..\.editorconfig
..\.gitignore = ..\.gitignore
..\.travis.yml = ..\.travis.yml
..\appveyor.yml = ..\appveyor.yml
..\global.json = ..\global.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Nuget", "Nuget", "{C7865979-1D1C-46AF-BDE8-1DA6F3ED81B3}"
ProjectSection(SolutionItems) = preProject
..\build\NEST.JsonNetSerializer.nuspec = ..\build\NEST.JsonNetSerializer.nuspec
..\build\NEST.nuspec = ..\build\NEST.nuspec
..\NuGet.config = ..\NuGet.config
..\build\Elasticsearch.Net.nuspec = ..\build\Elasticsearch.Net.nuspec
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Markdown", "Markdown", "{2FABB663-F4DB-499A-89F8-3A08828D1D91}"
ProjectSection(SolutionItems) = preProject
..\contributing.md = ..\contributing.md
..\license.txt = ..\license.txt
..\readme.md = ..\readme.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -80,7 +89,6 @@ Global
{56A87048-9065-459B-826D-3DF68B409845} = {93331BEE-0AA0-47B7-B1D2-BD5BD31634D1}
{98400F59-4BA8-4534-9A78-9C7FA0B42901} = {93331BEE-0AA0-47B7-B1D2-BD5BD31634D1}
{CDC8DEC8-3872-4337-9C40-9CDE5724BBDD} = {14241027-0A92-466D-B024-E0063F338915}
{D6997ADC-E933-418E-831C-DE1A78897493} = {432D5575-2347-4D3C-BF8C-3E38410C46CA}
{5B393962-7586-49BA-BD99-3B1E35F48E94} = {6C4A2627-AF22-4388-9DF7-7A9AEACFD635}
{BAA9802A-A664-4DB7-9A34-5FA84BEBDF81} = {6C4A2627-AF22-4388-9DF7-7A9AEACFD635}
{AC554BF8-8ED9-4C45-BB65-8833219CAC93} = {6C4A2627-AF22-4388-9DF7-7A9AEACFD635}
Expand All @@ -90,6 +98,9 @@ Global
{8C119416-DB47-4971-A9EC-566217241D95} = {6C4A2627-AF22-4388-9DF7-7A9AEACFD635}
{30FB80AE-3B37-4FBB-8450-9666969EEE1A} = {6C4A2627-AF22-4388-9DF7-7A9AEACFD635}
{CE7AC1D4-15AF-47FB-83FA-F7137DFD9076} = {6C4A2627-AF22-4388-9DF7-7A9AEACFD635}
{EAE89579-CCA9-45CE-AF83-3DCD98690EA8} = {432D5575-2347-4D3C-BF8C-3E38410C46CA}
{C7865979-1D1C-46AF-BDE8-1DA6F3ED81B3} = {432D5575-2347-4D3C-BF8C-3E38410C46CA}
{2FABB663-F4DB-499A-89F8-3A08828D1D91} = {432D5575-2347-4D3C-BF8C-3E38410C46CA}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5B393962-7586-49BA-BD99-3B1E35F48E94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Expand Down
28 changes: 28 additions & 0 deletions src/Library.build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project>
<!-- Sets up the common properties for all Elastic assemblies -->
<PropertyGroup>
<!-- Default Version numbers -->
<CurrentVersion>6.0.0</CurrentVersion>
<CurrentAssemblyVersion>6.0.0</CurrentAssemblyVersion>
<CurrentAssemblyFileVersion>6.0.0</CurrentAssemblyFileVersion>
<!-- Version and Informational reflect actual version -->
<Version>$(CurrentVersion)</Version>
<InformationalVersion>$(CurrentVersion)</InformationalVersion>
<!-- Assembly version is sticky to MAJOR.0.0.0 to avoid binding redirects because we strong name our assemblies -->
<AssemblyVersion>$(CurrentAssemblyVersion)</AssemblyVersion>
<!-- File version reflects actual version number without prelease since that not allowed in its struct -->
<FileVersion>$(CurrentAssemblyFileVersion)</FileVersion>

<DefineConstants Condition="'$(TargetFramework)'=='netstandard2.0'">$(DefineConstants);DOTNETCORE</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)'=='netcoreapp2.0'">$(DefineConstants);DOTNETCORE</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)'=='netcoreapp2.1'">$(DefineConstants);DOTNETCORE</DefineConstants>

<RepoUri>https://raw.githubusercontent.com/elastic/elasticsearch-net</RepoUri>
<Authors>Elasticsearch BV</Authors>
<Copyright>Elasticsearch BV</Copyright>
<PackageProjectUrl>https://github.com/elastic/elasticsearch-net</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/elastic/elasticsearch-net/blob/master/license.txt</PackageLicenseUrl>
<ReleaseNotes>See https://github.com/elastic/elasticsearch-net/releases</ReleaseNotes>
<PackageIconUrl>https://raw.githubusercontent.com/elastic/elasticsearch-net/master/build/nuget-icon.png</PackageIconUrl>
</PropertyGroup>
</Project>
3 changes: 1 addition & 2 deletions src/Nest/Nest.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\build\Clients.Common.targets" />
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.bat))\src\PublishArtifacts.build.props" />
<PropertyGroup>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard2.0</TargetFrameworks>
Expand All @@ -11,5 +11,4 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.1" />
</ItemGroup>
<Import Project="..\outputpath.props" />
</Project>
Loading