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

Commit 96a8b1b

Browse files
authored
Merge pull request #642 from justcoding121/master
netcoreapp2.1 target removed, use netstandard 2.1
2 parents e951ce9 + 35e3d3a commit 96a8b1b

18 files changed

+44
-60
lines changed

examples/Titanium.Web.Proxy.Examples.Basic/Titanium.Web.Proxy.Examples.Basic.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>net461;netcoreapp2.1</TargetFrameworks>
5+
<TargetFrameworks>net461;netcoreapp3.0</TargetFrameworks>
66
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
77
<LangVersion>7.1</LangVersion>
88
</PropertyGroup>

src/Titanium.Web.Proxy/ExplicitClientHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ await clientStreamWriter.WriteResponseAsync(connectArgs.HttpClient.Response,
210210
options.CertificateRevocationCheckMode = X509RevocationMode.NoCheck;
211211
await sslStream.AuthenticateAsServerAsync(options, cancellationToken);
212212

213-
#if NETCOREAPP2_1
213+
#if NETSTANDARD2_1
214214
clientConnection.NegotiatedApplicationProtocol = sslStream.NegotiatedApplicationProtocol;
215215
#endif
216216

@@ -336,7 +336,7 @@ await TcpHelper.SendRaw(clientStream, connection.Stream, BufferPool,
336336
await connection.StreamWriter.WriteLineAsync(cancellationToken);
337337
await connection.StreamWriter.WriteLineAsync("SM", cancellationToken);
338338
await connection.StreamWriter.WriteLineAsync(cancellationToken);
339-
#if NETCOREAPP2_1
339+
#if NETSTANDARD2_1
340340
await Http2Helper.SendHttp2(clientStream, connection.Stream,
341341
() => new SessionEventArgs(this, endPoint, cancellationTokenSource)
342342
{

src/Titanium.Web.Proxy/Extensions/SslExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal static string GetServerName(this ClientHelloInfo clientHelloInfo)
2828
return null;
2929
}
3030

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

81-
#if !NETCOREAPP2_1 && !NETSTANDARD2_1
81+
#if !NETSTANDARD2_1
8282
internal enum SslApplicationProtocol
8383
{
8484
Http11,

src/Titanium.Web.Proxy/Helpers/HttpHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ private static async Task<int> startsWith(ICustomStreamReader clientStreamReader
167167
while (i < lengthToCheck)
168168
{
169169
int peeked = await clientStreamReader.PeekBytesAsync(buffer, i, i, lengthToCheck - i, cancellationToken);
170-
if (peeked == 0)
170+
if (peeked <= 0)
171171
return -1;
172172

173173
peeked += i;

src/Titanium.Web.Proxy/Http2/Http2Helper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if NETCOREAPP2_1 || NETSTANDARD2_1
1+
#if NETSTANDARD2_1
22
using System;
33
using System.Collections.Concurrent;
44
using System.Collections.Generic;

src/Titanium.Web.Proxy/Network/Tcp/TcpClientConnection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.IO;
33
using System.Net;
4-
#if NETCOREAPP2_1 || NETSTANDARD2_1
4+
#if NETSTANDARD2_1
55
using System.Net.Security;
66
#endif
77
using System.Net.Sockets;

src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ private async Task<TcpServerConnection> createServerConnection(string remoteHost
391391
CertificateRevocationCheckMode = proxyServer.CheckCertificateRevocation
392392
};
393393
await sslStream.AuthenticateAsClientAsync(options, cancellationToken);
394-
#if NETCOREAPP2_1 || NETSTANDARD2_1
394+
#if NETSTANDARD2_1
395395
negotiatedApplicationProtocol = sslStream.NegotiatedApplicationProtocol;
396396
#endif
397397

src/Titanium.Web.Proxy/Network/Tcp/TcpServerConnection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22
using System.Net;
3-
#if NETCOREAPP2_1 || NETSTANDARD2_1
3+
#if NETSTANDARD2_1
44
using System.Net.Security;
55
#endif
66
using System.Net.Sockets;

src/Titanium.Web.Proxy/RequestHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Linq;
44
using System.Net;
55
using System.Net.Sockets;
6-
#if NETCOREAPP2_1 || NETSTANDARD2_1
6+
#if NETSTANDARD2_1
77
using System.Net.Security;
88
#endif
99
using System.Text.RegularExpressions;

src/Titanium.Web.Proxy/Titanium.Web.Proxy.csproj

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp2.1</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
55
<RootNamespace>Titanium.Web.Proxy</RootNamespace>
66
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
77
<SignAssembly>True</SignAssembly>
@@ -35,15 +35,6 @@
3535
</PackageReference>
3636
</ItemGroup>
3737

38-
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
39-
<PackageReference Include="Microsoft.Win32.Registry">
40-
<Version>4.6.0</Version>
41-
</PackageReference>
42-
<PackageReference Include="System.Security.Principal.Windows">
43-
<Version>4.6.0</Version>
44-
</PackageReference>
45-
</ItemGroup>
46-
4738
<ItemGroup>
4839
<Compile Update="Network\WinAuth\Security\Common.cs">
4940
<ExcludeFromSourceAnalysis>True</ExcludeFromSourceAnalysis>

src/Titanium.Web.Proxy/Titanium.Web.Proxy.nuspec

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,10 @@
2828
<dependency id="System.Buffers" version="4.5.0" />
2929
<dependency id="System.Security.Principal.Windows" version="4.6.0" />
3030
</group>
31-
<group targetFramework="netcoreapp2.1">
32-
<dependency id="Portable.BouncyCastle" version="1.8.5" />
33-
<dependency id="BrotliSharpLib" version="0.3.3" />
34-
<dependency id="Microsoft.Win32.Registry" version="4.6.0" />
35-
<dependency id="System.Buffers" version="4.5.0" />
36-
<dependency id="System.Security.Principal.Windows" version="4.6.0" />
37-
</group>
3831
</dependencies>
3932
</metadata>
4033
<files>
4134
<file src="bin\$configuration$\netstandard2.0\Titanium.Web.Proxy.dll" target="lib\netstandard2.0" />
4235
<file src="bin\$configuration$\netstandard2.1\Titanium.Web.Proxy.dll" target="lib\netstandard2.1" />
43-
<file src="bin\$configuration$\netcoreapp2.1\Titanium.Web.Proxy.dll" target="lib\netcoreapp2.1" />
4436
</files>
4537
</package>

tests/Titanium.Web.Proxy.IntegrationTests/ExpectContinueTests.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using Microsoft.AspNetCore.Http;
2-
using Microsoft.VisualStudio.TestTools.UnitTesting;
3-
using System;
1+
using System;
42
using System.Buffers;
53
using System.Collections.Generic;
64
using System.IO;
@@ -10,7 +8,7 @@
108
using System.Net.Sockets;
119
using System.Text;
1210
using System.Threading.Tasks;
13-
using Titanium.Web.Proxy.EventArguments;
11+
using Microsoft.VisualStudio.TestTools.UnitTesting;
1412
using Titanium.Web.Proxy.Http;
1513
using Titanium.Web.Proxy.IntegrationTests.Helpers;
1614

@@ -124,6 +122,7 @@ public async Task ReverseProxy_BeforeRequestThrows()
124122

125123
e.Respond(serverError);
126124
}
125+
127126
return Task.CompletedTask;
128127
};
129128

tests/Titanium.Web.Proxy.IntegrationTests/Helpers/HttpContinueClient.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public async Task<Response> Post(string server, int port, string content)
3939
var readTask = client.GetStream().ReadAsync(buffer, 0, 1024);
4040
if (!readTask.Wait(200))
4141
return null;
42+
4243
responseMsg += MsgEncoding.GetString(buffer, 0, readTask.Result);
4344
}
4445

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

5960
return response;
6061
}
61-
else
62-
{
63-
return response;
64-
}
62+
63+
return response;
6564
}
6665
}
6766
}

tests/Titanium.Web.Proxy.IntegrationTests/Helpers/HttpContinueServer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ private async Task<Request> ReadHeaders(PipeReader input)
6666
{
6767
Console.WriteLine($"{ex.GetType()}: {ex.Message}");
6868
}
69+
6970
return request;
7071
}
7172

@@ -87,6 +88,7 @@ private async Task<Request> ReadBody(Request request, PipeReader input)
8788
{
8889
Console.WriteLine($"{ex.GetType()}: {ex.Message}");
8990
}
91+
9092
return request;
9193
}
9294
}

tests/Titanium.Web.Proxy.IntegrationTests/Helpers/HttpMessageParsing.cs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ internal static class HttpMessageParsing
1212
/// http request, but it's good enough for testing purposes.
1313
/// </summary>
1414
/// <param name="messageText">The request message</param>
15+
/// <param name="requireBody"></param>
1516
/// <returns>Request object if message complete, null otherwise</returns>
1617
internal static Request ParseRequest(string messageText, bool requireBody)
1718
{
@@ -25,9 +26,7 @@ internal static Request ParseRequest(string messageText, bool requireBody)
2526
Request.ParseRequestLine(line, out var method, out var url, out var version);
2627
RequestResponseBase request = new Request()
2728
{
28-
Method = method,
29-
RequestUriString = url,
30-
HttpVersion = version
29+
Method = method, RequestUriString = url, HttpVersion = version
3130
};
3231
while (!string.IsNullOrEmpty(line = reader.ReadLine()))
3332
{
@@ -46,7 +45,10 @@ internal static Request ParseRequest(string messageText, bool requireBody)
4645
if (parseBody(reader, ref request))
4746
return request as Request;
4847
}
49-
catch { }
48+
catch
49+
{
50+
// ignore
51+
}
5052

5153
return null;
5254
}
@@ -63,14 +65,13 @@ internal static Response ParseResponse(string messageText)
6365
var line = reader.ReadLine();
6466
if (string.IsNullOrEmpty(line))
6567
return null;
68+
6669
try
6770
{
6871
Response.ParseResponseLine(line, out var version, out var status, out var desc);
6972
RequestResponseBase response = new Response()
7073
{
71-
HttpVersion = version,
72-
StatusCode = status,
73-
StatusDescription = desc
74+
HttpVersion = version, StatusCode = status, StatusDescription = desc
7475
};
7576

7677
while (!string.IsNullOrEmpty(line = reader.ReadLine()))
@@ -87,7 +88,10 @@ internal static Response ParseResponse(string messageText)
8788
if (parseBody(reader, ref response))
8889
return response as Response;
8990
}
90-
catch { }
91+
catch
92+
{
93+
// ignore
94+
}
9195

9296
return null;
9397
}
@@ -100,14 +104,11 @@ private static bool parseBody(StringReader reader, ref RequestResponseBase obj)
100104
// no body, done
101105
return true;
102106
}
103-
else
104-
{
105-
obj.Body = Encoding.ASCII.GetBytes(reader.ReadToEnd());
106-
if (obj.ContentLength == obj.OriginalContentLength)
107-
return true; // done reading body
108-
else
109-
return false; // not done reading body
110-
}
107+
108+
obj.Body = Encoding.ASCII.GetBytes(reader.ReadToEnd());
109+
110+
// done reading body
111+
return obj.ContentLength == obj.OriginalContentLength;
111112
}
112113
}
113114
}

tests/Titanium.Web.Proxy.IntegrationTests/NestedProxyTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
using Microsoft.AspNetCore.Http;
2-
using Microsoft.VisualStudio.TestTools.UnitTesting;
3-
using System;
1+
using System;
42
using System.Net;
53
using System.Net.Http;
64
using System.Net.Http.Headers;
75
using System.Text;
86
using System.Threading.Tasks;
7+
using Microsoft.AspNetCore.Http;
8+
using Microsoft.VisualStudio.TestTools.UnitTesting;
99

1010
namespace Titanium.Web.Proxy.IntegrationTests
1111
{

tests/Titanium.Web.Proxy.IntegrationTests/ReverseProxyTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using Microsoft.AspNetCore.Http;
2-
using Microsoft.VisualStudio.TestTools.UnitTesting;
3-
using System;
1+
using System;
42
using System.Net;
53
using System.Net.Http;
64
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Http;
6+
using Microsoft.VisualStudio.TestTools.UnitTesting;
77

88
namespace Titanium.Web.Proxy.IntegrationTests
99
{

tests/Titanium.Web.Proxy.IntegrationTests/Titanium.Web.Proxy.IntegrationTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.2</TargetFramework>
4+
<TargetFramework>netcoreapp3.0</TargetFramework>
55
<AssemblyOriginatorKeyFile>StrongNameKey.snk</AssemblyOriginatorKeyFile>
66
<SignAssembly>true</SignAssembly>
77
</PropertyGroup>

0 commit comments

Comments
 (0)