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

Commit 6b2348d

Browse files
committed
nullable fixes
1 parent d8dce11 commit 6b2348d

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

src/Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public abstract class SessionEventArgsBase : EventArgs, IDisposable
2222
{
2323
private static bool isWindowsAuthenticationSupported => RunTime.IsWindows;
2424

25-
internal readonly CancellationTokenSource CancellationTokenSource;
25+
internal readonly CancellationTokenSource? CancellationTokenSource;
2626

2727
internal TcpServerConnection ServerConnection => HttpClient.Connection;
2828

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ private async Task<TcpServerConnection> createServerConnection(string remoteHost
417417
throw;
418418
}
419419

420-
return new TcpServerConnection(proxyServer, tcpClient)
420+
return new TcpServerConnection(proxyServer, tcpClient, stream)
421421
{
422422
UpStreamProxy = externalProxy,
423423
UpStreamEndPoint = upStreamEndPoint,
@@ -426,8 +426,6 @@ private async Task<TcpServerConnection> createServerConnection(string remoteHost
426426
IsHttps = isHttps,
427427
NegotiatedApplicationProtocol = negotiatedApplicationProtocol,
428428
UseUpstreamProxy = useUpstreamProxy,
429-
StreamWriter = new HttpRequestWriter(stream, proxyServer.BufferPool),
430-
Stream = stream,
431429
Version = httpVersion
432430
};
433431
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ namespace Titanium.Web.Proxy.Network.Tcp
1515
/// </summary>
1616
internal class TcpServerConnection : IDisposable
1717
{
18-
internal TcpServerConnection(ProxyServer proxyServer, TcpClient tcpClient)
18+
internal TcpServerConnection(ProxyServer proxyServer, TcpClient tcpClient, CustomBufferedStream stream)
1919
{
2020
this.tcpClient = tcpClient;
2121
LastAccess = DateTime.Now;
2222
this.proxyServer = proxyServer;
2323
this.proxyServer.UpdateServerConnectionCount(true);
24+
StreamWriter = new HttpRequestWriter(stream, proxyServer.BufferPool);
25+
Stream = stream;
2426
}
2527

2628
private ProxyServer proxyServer { get; }
@@ -59,12 +61,12 @@ internal TcpServerConnection(ProxyServer proxyServer, TcpClient tcpClient)
5961
/// <summary>
6062
/// Used to write lines to server
6163
/// </summary>
62-
internal HttpRequestWriter? StreamWriter { get; set; }
64+
internal HttpRequestWriter StreamWriter { get; }
6365

6466
/// <summary>
6567
/// Server stream
6668
/// </summary>
67-
internal CustomBufferedStream? Stream { get; set; }
69+
internal CustomBufferedStream Stream { get; }
6870

6971
/// <summary>
7072
/// Last time this connection was used

src/Titanium.Web.Proxy/ProxyServer.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public partial class ProxyServer : IDisposable
5555
/// <summary>
5656
/// Upstream proxy manager.
5757
/// </summary>
58-
private WinHttpWebProxyFinder systemProxyResolver;
58+
private WinHttpWebProxyFinder? systemProxyResolver;
5959

6060

6161
/// <inheritdoc />
@@ -421,7 +421,7 @@ public void SetAsSystemHttpsProxy(ExplicitProxyEndPoint endPoint)
421421
/// <param name="protocolType">The proxy protocol type.</param>
422422
public void SetAsSystemProxy(ExplicitProxyEndPoint endPoint, ProxyProtocolType protocolType)
423423
{
424-
if (!RunTime.IsWindows)
424+
if (systemProxySettingsManager == null)
425425
{
426426
throw new NotSupportedException(@"Setting system proxy settings are only supported in Windows.
427427
Please manually confugure you operating system to use this proxy's port and address.");
@@ -515,7 +515,7 @@ public void DisableSystemHttpsProxy()
515515
/// </summary>
516516
public void RestoreOriginalProxySettings()
517517
{
518-
if (!RunTime.IsWindows)
518+
if (systemProxySettingsManager == null)
519519
{
520520
throw new NotSupportedException(@"Setting system proxy settings are only supported in Windows.
521521
Please manually configure your operating system to use this proxy's port and address.");
@@ -529,7 +529,7 @@ public void RestoreOriginalProxySettings()
529529
/// </summary>
530530
public void DisableSystemProxy(ProxyProtocolType protocolType)
531531
{
532-
if (!RunTime.IsWindows)
532+
if (systemProxySettingsManager == null)
533533
{
534534
throw new NotSupportedException(@"Setting system proxy settings are only supported in Windows.
535535
Please manually configure your operating system to use this proxy's port and address.");
@@ -543,7 +543,7 @@ public void DisableSystemProxy(ProxyProtocolType protocolType)
543543
/// </summary>
544544
public void DisableAllSystemProxies()
545545
{
546-
if (!RunTime.IsWindows)
546+
if (systemProxySettingsManager == null)
547547
{
548548
throw new NotSupportedException(@"Setting system proxy settings are only supported in Windows.
549549
Please manually confugure you operating system to use this proxy's port and address.");
@@ -622,7 +622,7 @@ public void Stop()
622622
throw new Exception("Proxy is not running.");
623623
}
624624

625-
if (RunTime.IsWindows && !RunTime.IsUwpOnWindows)
625+
if (systemProxySettingsManager != null)
626626
{
627627
bool setAsSystemProxy = ProxyEndPoints.OfType<ExplicitProxyEndPoint>()
628628
.Any(x => x.IsSystemHttpProxy || x.IsSystemHttpsProxy);

0 commit comments

Comments
 (0)