Commit 6b2348db authored by Honfika's avatar Honfika

nullable fixes

parent d8dce115
...@@ -22,7 +22,7 @@ namespace Titanium.Web.Proxy.EventArguments ...@@ -22,7 +22,7 @@ namespace Titanium.Web.Proxy.EventArguments
{ {
private static bool isWindowsAuthenticationSupported => RunTime.IsWindows; private static bool isWindowsAuthenticationSupported => RunTime.IsWindows;
internal readonly CancellationTokenSource CancellationTokenSource; internal readonly CancellationTokenSource? CancellationTokenSource;
internal TcpServerConnection ServerConnection => HttpClient.Connection; internal TcpServerConnection ServerConnection => HttpClient.Connection;
......
...@@ -417,7 +417,7 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -417,7 +417,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
throw; throw;
} }
return new TcpServerConnection(proxyServer, tcpClient) return new TcpServerConnection(proxyServer, tcpClient, stream)
{ {
UpStreamProxy = externalProxy, UpStreamProxy = externalProxy,
UpStreamEndPoint = upStreamEndPoint, UpStreamEndPoint = upStreamEndPoint,
...@@ -426,8 +426,6 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -426,8 +426,6 @@ namespace Titanium.Web.Proxy.Network.Tcp
IsHttps = isHttps, IsHttps = isHttps,
NegotiatedApplicationProtocol = negotiatedApplicationProtocol, NegotiatedApplicationProtocol = negotiatedApplicationProtocol,
UseUpstreamProxy = useUpstreamProxy, UseUpstreamProxy = useUpstreamProxy,
StreamWriter = new HttpRequestWriter(stream, proxyServer.BufferPool),
Stream = stream,
Version = httpVersion Version = httpVersion
}; };
} }
......
...@@ -15,12 +15,14 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -15,12 +15,14 @@ namespace Titanium.Web.Proxy.Network.Tcp
/// </summary> /// </summary>
internal class TcpServerConnection : IDisposable internal class TcpServerConnection : IDisposable
{ {
internal TcpServerConnection(ProxyServer proxyServer, TcpClient tcpClient) internal TcpServerConnection(ProxyServer proxyServer, TcpClient tcpClient, CustomBufferedStream stream)
{ {
this.tcpClient = tcpClient; this.tcpClient = tcpClient;
LastAccess = DateTime.Now; LastAccess = DateTime.Now;
this.proxyServer = proxyServer; this.proxyServer = proxyServer;
this.proxyServer.UpdateServerConnectionCount(true); this.proxyServer.UpdateServerConnectionCount(true);
StreamWriter = new HttpRequestWriter(stream, proxyServer.BufferPool);
Stream = stream;
} }
private ProxyServer proxyServer { get; } private ProxyServer proxyServer { get; }
...@@ -59,12 +61,12 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -59,12 +61,12 @@ namespace Titanium.Web.Proxy.Network.Tcp
/// <summary> /// <summary>
/// Used to write lines to server /// Used to write lines to server
/// </summary> /// </summary>
internal HttpRequestWriter? StreamWriter { get; set; } internal HttpRequestWriter StreamWriter { get; }
/// <summary> /// <summary>
/// Server stream /// Server stream
/// </summary> /// </summary>
internal CustomBufferedStream? Stream { get; set; } internal CustomBufferedStream Stream { get; }
/// <summary> /// <summary>
/// Last time this connection was used /// Last time this connection was used
......
...@@ -55,7 +55,7 @@ namespace Titanium.Web.Proxy ...@@ -55,7 +55,7 @@ namespace Titanium.Web.Proxy
/// <summary> /// <summary>
/// Upstream proxy manager. /// Upstream proxy manager.
/// </summary> /// </summary>
private WinHttpWebProxyFinder systemProxyResolver; private WinHttpWebProxyFinder? systemProxyResolver;
/// <inheritdoc /> /// <inheritdoc />
...@@ -421,7 +421,7 @@ namespace Titanium.Web.Proxy ...@@ -421,7 +421,7 @@ namespace Titanium.Web.Proxy
/// <param name="protocolType">The proxy protocol type.</param> /// <param name="protocolType">The proxy protocol type.</param>
public void SetAsSystemProxy(ExplicitProxyEndPoint endPoint, ProxyProtocolType protocolType) public void SetAsSystemProxy(ExplicitProxyEndPoint endPoint, ProxyProtocolType protocolType)
{ {
if (!RunTime.IsWindows) if (systemProxySettingsManager == null)
{ {
throw new NotSupportedException(@"Setting system proxy settings are only supported in Windows. throw new NotSupportedException(@"Setting system proxy settings are only supported in Windows.
Please manually confugure you operating system to use this proxy's port and address."); Please manually confugure you operating system to use this proxy's port and address.");
...@@ -515,7 +515,7 @@ namespace Titanium.Web.Proxy ...@@ -515,7 +515,7 @@ namespace Titanium.Web.Proxy
/// </summary> /// </summary>
public void RestoreOriginalProxySettings() public void RestoreOriginalProxySettings()
{ {
if (!RunTime.IsWindows) if (systemProxySettingsManager == null)
{ {
throw new NotSupportedException(@"Setting system proxy settings are only supported in Windows. throw new NotSupportedException(@"Setting system proxy settings are only supported in Windows.
Please manually configure your operating system to use this proxy's port and address."); Please manually configure your operating system to use this proxy's port and address.");
...@@ -529,7 +529,7 @@ namespace Titanium.Web.Proxy ...@@ -529,7 +529,7 @@ namespace Titanium.Web.Proxy
/// </summary> /// </summary>
public void DisableSystemProxy(ProxyProtocolType protocolType) public void DisableSystemProxy(ProxyProtocolType protocolType)
{ {
if (!RunTime.IsWindows) if (systemProxySettingsManager == null)
{ {
throw new NotSupportedException(@"Setting system proxy settings are only supported in Windows. throw new NotSupportedException(@"Setting system proxy settings are only supported in Windows.
Please manually configure your operating system to use this proxy's port and address."); Please manually configure your operating system to use this proxy's port and address.");
...@@ -543,7 +543,7 @@ namespace Titanium.Web.Proxy ...@@ -543,7 +543,7 @@ namespace Titanium.Web.Proxy
/// </summary> /// </summary>
public void DisableAllSystemProxies() public void DisableAllSystemProxies()
{ {
if (!RunTime.IsWindows) if (systemProxySettingsManager == null)
{ {
throw new NotSupportedException(@"Setting system proxy settings are only supported in Windows. throw new NotSupportedException(@"Setting system proxy settings are only supported in Windows.
Please manually confugure you operating system to use this proxy's port and address."); Please manually confugure you operating system to use this proxy's port and address.");
...@@ -622,7 +622,7 @@ namespace Titanium.Web.Proxy ...@@ -622,7 +622,7 @@ namespace Titanium.Web.Proxy
throw new Exception("Proxy is not running."); throw new Exception("Proxy is not running.");
} }
if (RunTime.IsWindows && !RunTime.IsUwpOnWindows) if (systemProxySettingsManager != null)
{ {
bool setAsSystemProxy = ProxyEndPoints.OfType<ExplicitProxyEndPoint>() bool setAsSystemProxy = ProxyEndPoints.OfType<ExplicitProxyEndPoint>()
.Any(x => x.IsSystemHttpProxy || x.IsSystemHttpsProxy); .Any(x => x.IsSystemHttpProxy || x.IsSystemHttpsProxy);
......
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