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

Commit 4febcb0

Browse files
committed
less exceptions
1 parent 4f43bd1 commit 4febcb0

File tree

5 files changed

+216
-63
lines changed

5 files changed

+216
-63
lines changed

examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public ProxyTestController()
2626
{
2727
proxyServer = new ProxyServer();
2828

29-
proxyServer.EnableHttp2 = true;
29+
//proxyServer.EnableHttp2 = true;
3030

3131
// generate root certificate without storing it in file system
3232
//proxyServer.CertificateManager.CreateRootCertificate(false);

src/Titanium.Web.Proxy/ExplicitClientHandler.cs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -141,26 +141,29 @@ private async Task handleClient(ExplicitProxyEndPoint endPoint, TcpClientConnect
141141

142142
bool http2Supported = false;
143143

144-
var alpn = clientHelloInfo.GetAlpn();
145-
if (alpn != null && alpn.Contains(SslApplicationProtocol.Http2))
144+
if (EnableHttp2)
146145
{
147-
// test server HTTP/2 support
148-
try
149-
{
150-
// todo: this is a hack, because Titanium does not support HTTP protocol changing currently
151-
var connection = await tcpConnectionFactory.GetServerConnection(this, connectArgs,
152-
true, SslExtensions.Http2ProtocolAsList,
153-
true, cancellationToken);
154-
155-
http2Supported = connection.NegotiatedApplicationProtocol ==
156-
SslApplicationProtocol.Http2;
157-
158-
// release connection back to pool instead of closing when connection pool is enabled.
159-
await tcpConnectionFactory.Release(connection, true);
160-
}
161-
catch (Exception)
146+
var alpn = clientHelloInfo.GetAlpn();
147+
if (alpn != null && alpn.Contains(SslApplicationProtocol.Http2))
162148
{
163-
// ignore
149+
// test server HTTP/2 support
150+
try
151+
{
152+
// todo: this is a hack, because Titanium does not support HTTP protocol changing currently
153+
var connection = await tcpConnectionFactory.GetServerConnection(this, connectArgs,
154+
true, SslExtensions.Http2ProtocolAsList,
155+
true, cancellationToken);
156+
157+
http2Supported = connection.NegotiatedApplicationProtocol ==
158+
SslApplicationProtocol.Http2;
159+
160+
// release connection back to pool instead of closing when connection pool is enabled.
161+
await tcpConnectionFactory.Release(connection, true);
162+
}
163+
catch (Exception)
164+
{
165+
// ignore
166+
}
164167
}
165168
}
166169

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

280283
try

0 commit comments

Comments
 (0)