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

netcoreapp2.1 target removed, use netstandard 2.1 #642

Merged
merged 1 commit into from
Oct 6, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net461;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net461;netcoreapp3.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Titanium.Web.Proxy/ExplicitClientHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ await clientStreamWriter.WriteResponseAsync(connectArgs.HttpClient.Response,
options.CertificateRevocationCheckMode = X509RevocationMode.NoCheck;
await sslStream.AuthenticateAsServerAsync(options, cancellationToken);

#if NETCOREAPP2_1
#if NETSTANDARD2_1
clientConnection.NegotiatedApplicationProtocol = sslStream.NegotiatedApplicationProtocol;
#endif

Expand Down Expand Up @@ -336,7 +336,7 @@ await TcpHelper.SendRaw(clientStream, connection.Stream, BufferPool,
await connection.StreamWriter.WriteLineAsync(cancellationToken);
await connection.StreamWriter.WriteLineAsync("SM", cancellationToken);
await connection.StreamWriter.WriteLineAsync(cancellationToken);
#if NETCOREAPP2_1
#if NETSTANDARD2_1
await Http2Helper.SendHttp2(clientStream, connection.Stream,
() => new SessionEventArgs(this, endPoint, cancellationTokenSource)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Titanium.Web.Proxy/Extensions/SslExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal static string GetServerName(this ClientHelloInfo clientHelloInfo)
return null;
}

#if NETCOREAPP2_1 || NETSTANDARD2_1
#if NETSTANDARD2_1
internal static List<SslApplicationProtocol> GetAlpn(this ClientHelloInfo clientHelloInfo)
{
if (clientHelloInfo.Extensions != null && clientHelloInfo.Extensions.TryGetValue("ALPN", out var alpnExtension))
Expand Down Expand Up @@ -78,7 +78,7 @@ internal static Task AuthenticateAsServerAsync(this SslStream sslStream, SslServ
#endif
}

#if !NETCOREAPP2_1 && !NETSTANDARD2_1
#if !NETSTANDARD2_1
internal enum SslApplicationProtocol
{
Http11,
Expand Down
2 changes: 1 addition & 1 deletion src/Titanium.Web.Proxy/Helpers/HttpHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private static async Task<int> startsWith(ICustomStreamReader clientStreamReader
while (i < lengthToCheck)
{
int peeked = await clientStreamReader.PeekBytesAsync(buffer, i, i, lengthToCheck - i, cancellationToken);
if (peeked == 0)
if (peeked <= 0)
return -1;

peeked += i;
Expand Down
2 changes: 1 addition & 1 deletion src/Titanium.Web.Proxy/Http2/Http2Helper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETCOREAPP2_1 || NETSTANDARD2_1
#if NETSTANDARD2_1
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
Expand Down
2 changes: 1 addition & 1 deletion src/Titanium.Web.Proxy/Network/Tcp/TcpClientConnection.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.IO;
using System.Net;
#if NETCOREAPP2_1 || NETSTANDARD2_1
#if NETSTANDARD2_1
using System.Net.Security;
#endif
using System.Net.Sockets;
Expand Down
2 changes: 1 addition & 1 deletion src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ private async Task<TcpServerConnection> createServerConnection(string remoteHost
CertificateRevocationCheckMode = proxyServer.CheckCertificateRevocation
};
await sslStream.AuthenticateAsClientAsync(options, cancellationToken);
#if NETCOREAPP2_1 || NETSTANDARD2_1
#if NETSTANDARD2_1
negotiatedApplicationProtocol = sslStream.NegotiatedApplicationProtocol;
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/Titanium.Web.Proxy/Network/Tcp/TcpServerConnection.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Net;
#if NETCOREAPP2_1 || NETSTANDARD2_1
#if NETSTANDARD2_1
using System.Net.Security;
#endif
using System.Net.Sockets;
Expand Down
2 changes: 1 addition & 1 deletion src/Titanium.Web.Proxy/RequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using System.Net;
using System.Net.Sockets;
#if NETCOREAPP2_1 || NETSTANDARD2_1
#if NETSTANDARD2_1
using System.Net.Security;
#endif
using System.Text.RegularExpressions;
Expand Down
11 changes: 1 addition & 10 deletions src/Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<RootNamespace>Titanium.Web.Proxy</RootNamespace>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<SignAssembly>True</SignAssembly>
Expand Down Expand Up @@ -35,15 +35,6 @@
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PackageReference Include="Microsoft.Win32.Registry">
<Version>4.6.0</Version>
</PackageReference>
<PackageReference Include="System.Security.Principal.Windows">
<Version>4.6.0</Version>
</PackageReference>
</ItemGroup>

<ItemGroup>
<Compile Update="Network\WinAuth\Security\Common.cs">
<ExcludeFromSourceAnalysis>True</ExcludeFromSourceAnalysis>
Expand Down
8 changes: 0 additions & 8 deletions src/Titanium.Web.Proxy/Titanium.Web.Proxy.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,10 @@
<dependency id="System.Buffers" version="4.5.0" />
<dependency id="System.Security.Principal.Windows" version="4.6.0" />
</group>
<group targetFramework="netcoreapp2.1">
<dependency id="Portable.BouncyCastle" version="1.8.5" />
<dependency id="BrotliSharpLib" version="0.3.3" />
<dependency id="Microsoft.Win32.Registry" version="4.6.0" />
<dependency id="System.Buffers" version="4.5.0" />
<dependency id="System.Security.Principal.Windows" version="4.6.0" />
</group>
</dependencies>
</metadata>
<files>
<file src="bin\$configuration$\netstandard2.0\Titanium.Web.Proxy.dll" target="lib\netstandard2.0" />
<file src="bin\$configuration$\netstandard2.1\Titanium.Web.Proxy.dll" target="lib\netstandard2.1" />
<file src="bin\$configuration$\netcoreapp2.1\Titanium.Web.Proxy.dll" target="lib\netcoreapp2.1" />
</files>
</package>
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Microsoft.AspNetCore.Http;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System;
using System.Buffers;
using System.Collections.Generic;
using System.IO;
Expand All @@ -10,7 +8,7 @@
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using Titanium.Web.Proxy.EventArguments;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Titanium.Web.Proxy.Http;
using Titanium.Web.Proxy.IntegrationTests.Helpers;

Expand Down Expand Up @@ -124,6 +122,7 @@ public async Task ReverseProxy_BeforeRequestThrows()

e.Respond(serverError);
}

return Task.CompletedTask;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public async Task<Response> Post(string server, int port, string content)
var readTask = client.GetStream().ReadAsync(buffer, 0, 1024);
if (!readTask.Wait(200))
return null;

responseMsg += MsgEncoding.GetString(buffer, 0, readTask.Result);
}

Expand All @@ -58,10 +59,8 @@ public async Task<Response> Post(string server, int port, string content)

return response;
}
else
{
return response;
}

return response;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private async Task<Request> ReadHeaders(PipeReader input)
{
Console.WriteLine($"{ex.GetType()}: {ex.Message}");
}

return request;
}

Expand All @@ -87,6 +88,7 @@ private async Task<Request> ReadBody(Request request, PipeReader input)
{
Console.WriteLine($"{ex.GetType()}: {ex.Message}");
}

return request;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ internal static class HttpMessageParsing
/// http request, but it's good enough for testing purposes.
/// </summary>
/// <param name="messageText">The request message</param>
/// <param name="requireBody"></param>
/// <returns>Request object if message complete, null otherwise</returns>
internal static Request ParseRequest(string messageText, bool requireBody)
{
Expand All @@ -25,9 +26,7 @@ internal static Request ParseRequest(string messageText, bool requireBody)
Request.ParseRequestLine(line, out var method, out var url, out var version);
RequestResponseBase request = new Request()
{
Method = method,
RequestUriString = url,
HttpVersion = version
Method = method, RequestUriString = url, HttpVersion = version
};
while (!string.IsNullOrEmpty(line = reader.ReadLine()))
{
Expand All @@ -46,7 +45,10 @@ internal static Request ParseRequest(string messageText, bool requireBody)
if (parseBody(reader, ref request))
return request as Request;
}
catch { }
catch
{
// ignore
}

return null;
}
Expand All @@ -63,14 +65,13 @@ internal static Response ParseResponse(string messageText)
var line = reader.ReadLine();
if (string.IsNullOrEmpty(line))
return null;

try
{
Response.ParseResponseLine(line, out var version, out var status, out var desc);
RequestResponseBase response = new Response()
{
HttpVersion = version,
StatusCode = status,
StatusDescription = desc
HttpVersion = version, StatusCode = status, StatusDescription = desc
};

while (!string.IsNullOrEmpty(line = reader.ReadLine()))
Expand All @@ -87,7 +88,10 @@ internal static Response ParseResponse(string messageText)
if (parseBody(reader, ref response))
return response as Response;
}
catch { }
catch
{
// ignore
}

return null;
}
Expand All @@ -100,14 +104,11 @@ private static bool parseBody(StringReader reader, ref RequestResponseBase obj)
// no body, done
return true;
}
else
{
obj.Body = Encoding.ASCII.GetBytes(reader.ReadToEnd());
if (obj.ContentLength == obj.OriginalContentLength)
return true; // done reading body
else
return false; // not done reading body
}

obj.Body = Encoding.ASCII.GetBytes(reader.ReadToEnd());

// done reading body
return obj.ContentLength == obj.OriginalContentLength;
}
}
}
6 changes: 3 additions & 3 deletions tests/Titanium.Web.Proxy.IntegrationTests/NestedProxyTests.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Microsoft.AspNetCore.Http;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Titanium.Web.Proxy.IntegrationTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Http;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Titanium.Web.Proxy.IntegrationTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyOriginatorKeyFile>StrongNameKey.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
Expand Down