Unverified Commit f9a74d7b authored by honfika's avatar honfika Committed by GitHub

Merge pull request #691 from justcoding121/master

less exceptions
parents b81baeca 4febcb05
...@@ -26,7 +26,7 @@ namespace Titanium.Web.Proxy.Examples.Basic ...@@ -26,7 +26,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
{ {
proxyServer = new ProxyServer(); proxyServer = new ProxyServer();
proxyServer.EnableHttp2 = true; //proxyServer.EnableHttp2 = true;
// generate root certificate without storing it in file system // generate root certificate without storing it in file system
//proxyServer.CertificateManager.CreateRootCertificate(false); //proxyServer.CertificateManager.CreateRootCertificate(false);
......
...@@ -141,6 +141,8 @@ namespace Titanium.Web.Proxy ...@@ -141,6 +141,8 @@ namespace Titanium.Web.Proxy
bool http2Supported = false; bool http2Supported = false;
if (EnableHttp2)
{
var alpn = clientHelloInfo.GetAlpn(); var alpn = clientHelloInfo.GetAlpn();
if (alpn != null && alpn.Contains(SslApplicationProtocol.Http2)) if (alpn != null && alpn.Contains(SslApplicationProtocol.Http2))
{ {
...@@ -163,6 +165,7 @@ namespace Titanium.Web.Proxy ...@@ -163,6 +165,7 @@ namespace Titanium.Web.Proxy
// ignore // ignore
} }
} }
}
if (EnableTcpServerConnectionPrefetch) if (EnableTcpServerConnectionPrefetch)
{ {
...@@ -274,7 +277,7 @@ namespace Titanium.Web.Proxy ...@@ -274,7 +277,7 @@ namespace Titanium.Web.Proxy
// If we detected that client tunnel CONNECTs without SSL by checking for empty client hello then // If we detected that client tunnel CONNECTs without SSL by checking for empty client hello then
// this connection should not be HTTPS. // this connection should not be HTTPS.
var connection = await tcpConnectionFactory.GetServerConnection(this, connectArgs, var connection = await tcpConnectionFactory.GetServerConnection(this, connectArgs,
true, SslExtensions.Http2ProtocolAsList, true, null,
true, cancellationToken); true, cancellationToken);
try try
......
...@@ -2,25 +2,24 @@ ...@@ -2,25 +2,24 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Titanium.Web.Proxy.StreamExtended.Network; using Titanium.Web.Proxy.StreamExtended.Network;
internal class NullWriter : IHttpStreamWriter namespace Titanium.Web.Proxy.Helpers
{ {
internal class NullWriter : IHttpStreamWriter
{
public static NullWriter Instance { get; } = new NullWriter(); public static NullWriter Instance { get; } = new NullWriter();
public void Write(byte[] buffer, int offset, int count) public void Write(byte[] buffer, int offset, int count)
{ {
} }
#if NET45
public async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
{
}
#else
public Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) public Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
{ {
#if NET45
return Net45Compatibility.CompletedTask;
#else
return Task.CompletedTask; return Task.CompletedTask;
}
#endif #endif
}
public ValueTask WriteLineAsync(CancellationToken cancellationToken = default) public ValueTask WriteLineAsync(CancellationToken cancellationToken = default)
{ {
...@@ -31,4 +30,5 @@ internal class NullWriter : IHttpStreamWriter ...@@ -31,4 +30,5 @@ internal class NullWriter : IHttpStreamWriter
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
}
} }
...@@ -10,6 +10,8 @@ namespace Titanium.Web.Proxy ...@@ -10,6 +10,8 @@ namespace Titanium.Web.Proxy
class Net45Compatibility class Net45Compatibility
{ {
public static byte[] EmptyArray = new byte[0]; public static byte[] EmptyArray = new byte[0];
public static Task CompletedTask = new Task(() => { });
} }
} }
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment