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

less exceptions #691

Merged
merged 1 commit into from
Nov 30, 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 @@ -26,7 +26,7 @@ public ProxyTestController()
{
proxyServer = new ProxyServer();

proxyServer.EnableHttp2 = true;
//proxyServer.EnableHttp2 = true;

// generate root certificate without storing it in file system
//proxyServer.CertificateManager.CreateRootCertificate(false);
Expand Down
41 changes: 22 additions & 19 deletions src/Titanium.Web.Proxy/ExplicitClientHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,26 +141,29 @@ private async Task handleClient(ExplicitProxyEndPoint endPoint, TcpClientConnect

bool http2Supported = false;

var alpn = clientHelloInfo.GetAlpn();
if (alpn != null && alpn.Contains(SslApplicationProtocol.Http2))
if (EnableHttp2)
{
// test server HTTP/2 support
try
{
// todo: this is a hack, because Titanium does not support HTTP protocol changing currently
var connection = await tcpConnectionFactory.GetServerConnection(this, connectArgs,
true, SslExtensions.Http2ProtocolAsList,
true, cancellationToken);

http2Supported = connection.NegotiatedApplicationProtocol ==
SslApplicationProtocol.Http2;

// release connection back to pool instead of closing when connection pool is enabled.
await tcpConnectionFactory.Release(connection, true);
}
catch (Exception)
var alpn = clientHelloInfo.GetAlpn();
if (alpn != null && alpn.Contains(SslApplicationProtocol.Http2))
{
// ignore
// test server HTTP/2 support
try
{
// todo: this is a hack, because Titanium does not support HTTP protocol changing currently
var connection = await tcpConnectionFactory.GetServerConnection(this, connectArgs,
true, SslExtensions.Http2ProtocolAsList,
true, cancellationToken);

http2Supported = connection.NegotiatedApplicationProtocol ==
SslApplicationProtocol.Http2;

// release connection back to pool instead of closing when connection pool is enabled.
await tcpConnectionFactory.Release(connection, true);
}
catch (Exception)
{
// ignore
}
}
}

Expand Down Expand Up @@ -274,7 +277,7 @@ private async Task handleClient(ExplicitProxyEndPoint endPoint, TcpClientConnect
// If we detected that client tunnel CONNECTs without SSL by checking for empty client hello then
// this connection should not be HTTPS.
var connection = await tcpConnectionFactory.GetServerConnection(this, connectArgs,
true, SslExtensions.Http2ProtocolAsList,
true, null,
true, cancellationToken);

try
Expand Down
Loading