Commit d8dce115 authored by Honfika's avatar Honfika

Nullable fixes

parent 8a0244ba
......@@ -45,12 +45,12 @@ namespace Titanium.Web.Proxy.EventArguments
/// <summary>
/// Fired when decrypted data is sent within this session to server/client.
/// </summary>
public event EventHandler<DataEventArgs> DecryptedDataSent;
public event EventHandler<DataEventArgs>? DecryptedDataSent;
/// <summary>
/// Fired when decrypted data is received within this session from client/server.
/// </summary>
public event EventHandler<DataEventArgs> DecryptedDataReceived;
public event EventHandler<DataEventArgs>? DecryptedDataReceived;
internal void OnDecryptedDataSent(byte[] buffer, int offset, int count)
{
......
......@@ -309,7 +309,7 @@ namespace Titanium.Web.Proxy
connectArgs.HttpClient.ConnectRequest!.TunnelType = TunnelType.Http2;
// HTTP/2 Connection Preface
string line = await clientStream.ReadLineAsync(cancellationToken);
string? line = await clientStream.ReadLineAsync(cancellationToken);
if (line != string.Empty)
{
throw new Exception($"HTTP/2 Protocol violation. Empty string expected, '{line}' received");
......@@ -332,11 +332,9 @@ namespace Titanium.Web.Proxy
noCache: true, cancellationToken: cancellationToken);
try
{
await connection.StreamWriter.WriteLineAsync("PRI * HTTP/2.0", cancellationToken);
await connection.StreamWriter.WriteLineAsync(cancellationToken);
await connection.StreamWriter.WriteLineAsync("SM", cancellationToken);
await connection.StreamWriter.WriteLineAsync(cancellationToken);
#if NETSTANDARD2_1
var connectionPreface = new ReadOnlyMemory<byte>(Http2Helper.ConnectionPreface);
await connection.StreamWriter.WriteAsync(connectionPreface, cancellationToken);
await Http2Helper.SendHttp2(clientStream, connection.Stream,
() => new SessionEventArgs(this, endPoint, cancellationTokenSource)
{
......
......@@ -77,15 +77,19 @@ namespace Titanium.Web.Proxy.Extensions
}
#endif
}
}
#if !NETSTANDARD2_1
namespace System.Net.Security
{
internal enum SslApplicationProtocol
{
Http11,
Http2
}
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleType", Justification = "Reviewed.")]
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleType", Justification =
"Reviewed.")]
internal class SslClientAuthenticationOptions
{
internal bool AllowRenegotiation { get; set; }
......@@ -125,5 +129,5 @@ namespace Titanium.Web.Proxy.Extensions
internal EncryptionPolicy EncryptionPolicy { get; set; }
}
#endif
}
#endif
......@@ -32,7 +32,7 @@ namespace Titanium.Web.Proxy.Extensions
/// <param name="onCopy"></param>
/// <param name="bufferPool"></param>
/// <param name="cancellationToken"></param>
internal static async Task CopyToAsync(this Stream input, Stream output, Action<byte[], int, int> onCopy,
internal static async Task CopyToAsync(this Stream input, Stream output, Action<byte[], int, int>? onCopy,
IBufferPool bufferPool, CancellationToken cancellationToken)
{
var buffer = bufferPool.GetBuffer();
......
......@@ -66,7 +66,7 @@ namespace Titanium.Web.Proxy.Helpers
/// </summary>
/// <param name="contentType"></param>
/// <returns></returns>
internal static Encoding GetEncodingFromContentType(string contentType)
internal static Encoding GetEncodingFromContentType(string? contentType)
{
try
{
......@@ -108,7 +108,7 @@ namespace Titanium.Web.Proxy.Helpers
return defaultEncoding;
}
internal static ReadOnlyMemory<char> GetBoundaryFromContentType(string contentType)
internal static ReadOnlyMemory<char> GetBoundaryFromContentType(string? contentType)
{
if (contentType != null)
{
......@@ -196,16 +196,14 @@ namespace Titanium.Web.Proxy.Helpers
private static async Task<int> startsWith(ICustomStreamReader clientStreamReader, IBufferPool bufferPool, string expectedStart, CancellationToken cancellationToken = default)
{
const int lengthToCheck = 10;
byte[]? buffer = null;
try
if (bufferPool.BufferSize < lengthToCheck)
{
if (bufferPool.BufferSize < lengthToCheck)
{
throw new Exception($"Buffer is too small. Minimum size is {lengthToCheck} bytes");
}
buffer = bufferPool.GetBuffer(bufferPool.BufferSize);
throw new Exception($"Buffer is too small. Minimum size is {lengthToCheck} bytes");
}
byte[] buffer = bufferPool.GetBuffer(bufferPool.BufferSize);
try
{
bool isExpected = true;
int i = 0;
while (i < lengthToCheck)
......
......@@ -192,8 +192,7 @@ namespace Titanium.Web.Proxy.Helpers
/// <param name="onCopy"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
private async Task copyBodyChunkedAsync(ICustomStreamReader reader, Action<byte[], int, int> onCopy,
CancellationToken cancellationToken)
private async Task copyBodyChunkedAsync(ICustomStreamReader reader, Action<byte[], int, int>? onCopy, CancellationToken cancellationToken)
{
while (true)
{
......@@ -233,7 +232,7 @@ namespace Titanium.Web.Proxy.Helpers
/// <param name="onCopy"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
private async Task copyBytesFromStream(ICustomStreamReader reader, long count, Action<byte[], int, int> onCopy,
private async Task copyBytesFromStream(ICustomStreamReader reader, long count, Action<byte[], int, int>? onCopy,
CancellationToken cancellationToken)
{
var buffer = bufferPool.GetBuffer();
......
......@@ -158,7 +158,7 @@ namespace Titanium.Web.Proxy.Helpers
/// </summary>
/// <param name="proxyServerValues"></param>
/// <returns></returns>
internal static List<HttpSystemProxyValue> GetSystemProxyValues(string proxyServerValues)
internal static List<HttpSystemProxyValue> GetSystemProxyValues(string? proxyServerValues)
{
var result = new List<HttpSystemProxyValue>();
......@@ -167,7 +167,7 @@ namespace Titanium.Web.Proxy.Helpers
return result;
}
var proxyValues = proxyServerValues.Split(';');
var proxyValues = proxyServerValues!.Split(';');
if (proxyValues.Length > 0)
{
......
......@@ -10,10 +10,10 @@ namespace Titanium.Web.Proxy.Http
internal static async Task ReadHeaders(ICustomStreamReader reader, HeaderCollection headerCollection,
CancellationToken cancellationToken)
{
string tmpLine;
string? tmpLine;
while (!string.IsNullOrEmpty(tmpLine = await reader.ReadLineAsync(cancellationToken)))
{
int colonIndex = tmpLine.IndexOf(':');
int colonIndex = tmpLine!.IndexOf(':');
if (colonIndex == -1)
{
throw new Exception("Header line should contain a colon character.");
......
......@@ -60,7 +60,7 @@ namespace Titanium.Web.Proxy.Http
/// <summary>
/// Override UpStreamEndPoint for this request; Local NIC via request is made
/// </summary>
public IPEndPoint UpStreamEndPoint { get; set; }
public IPEndPoint? UpStreamEndPoint { get; set; }
/// <summary>
/// Headers passed with Connect.
......@@ -182,11 +182,8 @@ namespace Titanium.Web.Proxy.Http
string httpStatus;
try
{
httpStatus = await Connection.Stream.ReadLineAsync(cancellationToken);
if (httpStatus == null)
{
throw new ServerConnectionException("Server connection was closed.");
}
httpStatus = await Connection.Stream.ReadLineAsync(cancellationToken) ??
throw new ServerConnectionException("Server connection was closed.");
}
catch (Exception e) when (!(e is ServerConnectionException))
{
......@@ -195,7 +192,8 @@ namespace Titanium.Web.Proxy.Http
if (httpStatus == string.Empty)
{
httpStatus = await Connection.Stream.ReadLineAsync(cancellationToken);
httpStatus = await Connection.Stream.ReadLineAsync(cancellationToken) ??
throw new ServerConnectionException("Server connection was closed.");
}
Response.ParseResponseLine(httpStatus, out var version, out int statusCode, out string statusDescription);
......
......@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Titanium.Web.Proxy.Compression;
......@@ -12,11 +13,15 @@ using Titanium.Web.Proxy.EventArguments;
using Titanium.Web.Proxy.Exceptions;
using Titanium.Web.Proxy.Http;
using Titanium.Web.Proxy.Http2.Hpack;
using Decoder = Titanium.Web.Proxy.Http2.Hpack.Decoder;
using Encoder = Titanium.Web.Proxy.Http2.Hpack.Encoder;
namespace Titanium.Web.Proxy.Http2
{
internal class Http2Helper
{
public static readonly byte[] ConnectionPreface = Encoding.ASCII.GetBytes("PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n");
/// <summary>
/// relays the input clientStream to the server at the specified host name and port with the given httpCmd and headers
/// as prefix
......
......@@ -52,8 +52,8 @@ namespace Titanium.Web.Proxy.Network
/// Useful to prevent multiple threads working on same certificate generation
/// when burst certificate generation requests happen for same certificate.
/// </summary>
private readonly ConcurrentDictionary<string, Task<X509Certificate2>> pendingCertificateCreationTasks
= new ConcurrentDictionary<string, Task<X509Certificate2>>();
private readonly ConcurrentDictionary<string, Task<X509Certificate2?>> pendingCertificateCreationTasks
= new ConcurrentDictionary<string, Task<X509Certificate2?>>();
private readonly CancellationTokenSource clearCertificatesTokenSource
= new CancellationTokenSource();
......@@ -334,8 +334,7 @@ namespace Titanium.Web.Proxy.Network
/// <param name="storeName"></param>
/// <param name="storeLocation"></param>
/// <param name="certificate"></param>
private void uninstallCertificate(StoreName storeName, StoreLocation storeLocation,
X509Certificate2 certificate)
private void uninstallCertificate(StoreName storeName, StoreLocation storeLocation, X509Certificate2? certificate)
{
if (certificate == null)
{
......@@ -447,7 +446,7 @@ namespace Titanium.Web.Proxy.Network
/// </summary>
/// <param name="certificateName"></param>
/// <returns></returns>
public async Task<X509Certificate2> CreateServerCertificate(string certificateName)
public async Task<X509Certificate2?> CreateServerCertificate(string certificateName)
{
// check in cache first
if (cachedCertificates.TryGetValue(certificateName, out var cached))
......
......@@ -7,7 +7,7 @@ namespace Titanium.Web.Proxy.Network
/// <summary>
/// Loads the root certificate from the storage.
/// </summary>
X509Certificate2 LoadRootCertificate(string pathOrName, string password, X509KeyStorageFlags storageFlags);
X509Certificate2? LoadRootCertificate(string pathOrName, string password, X509KeyStorageFlags storageFlags);
/// <summary>
/// Saves the root certificate to the storage.
......@@ -17,7 +17,7 @@ namespace Titanium.Web.Proxy.Network
/// <summary>
/// Loads certificate from the storage. Returns true if certificate does not exist.
/// </summary>
X509Certificate2 LoadCertificate(string subjectName, X509KeyStorageFlags storageFlags);
X509Certificate2? LoadCertificate(string subjectName, X509KeyStorageFlags storageFlags);
/// <summary>
/// Stores certificate into the storage.
......
......@@ -25,7 +25,7 @@ namespace Titanium.Web.Proxy.Network
/// <param name="initialConnection">Initial Tcp connection to use.</param>
/// <returns>Returns the latest connection used and the latest exception if any.</returns>
internal async Task<RetryResult> ExecuteAsync(Func<TcpServerConnection, Task<bool>> action,
Func<Task<TcpServerConnection>> generator, TcpServerConnection initialConnection)
Func<Task<TcpServerConnection>> generator, TcpServerConnection? initialConnection)
{
currentConnection = initialConnection;
bool @continue = true;
......@@ -79,15 +79,13 @@ namespace Titanium.Web.Proxy.Network
internal class RetryResult
{
internal bool IsSuccess => Exception == null;
internal TcpServerConnection LatestConnection { get; }
internal TcpServerConnection? LatestConnection { get; }
internal Exception? Exception { get; }
internal bool Continue { get; }
internal RetryResult(TcpServerConnection lastConnection, Exception? exception, bool @continue)
internal RetryResult(TcpServerConnection? lastConnection, Exception? exception, bool @continue)
{
LatestConnection = lastConnection;
Exception = exception;
......
using System;
using System.IO;
using System.Net;
#if NETSTANDARD2_1
using System.Net.Security;
#endif
using System.Net.Sockets;
using System.Security.Authentication;
using System.Threading.Tasks;
......
......@@ -48,7 +48,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
internal string GetConnectionCacheKey(string remoteHostName, int remotePort,
bool isHttps, List<SslApplicationProtocol>? applicationProtocols,
IPEndPoint upStreamEndPoint, ExternalProxy externalProxy)
IPEndPoint upStreamEndPoint, ExternalProxy? externalProxy)
{
// http version is ignored since its an application level decision b/w HTTP 1.0/1.1
// also when doing connect request MS Edge browser sends http 1.0 but uses 1.1 after server sends 1.1 its response.
......@@ -180,7 +180,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
/// <returns></returns>
internal async Task<TcpServerConnection> GetServerConnection(string remoteHostName, int remotePort,
Version httpVersion, bool isHttps, List<SslApplicationProtocol>? applicationProtocols, bool isConnect,
ProxyServer proxyServer, SessionEventArgsBase? session, IPEndPoint upStreamEndPoint, ExternalProxy externalProxy,
ProxyServer proxyServer, SessionEventArgsBase? session, IPEndPoint upStreamEndPoint, ExternalProxy? externalProxy,
bool noCache, CancellationToken cancellationToken)
{
var sslProtocol = session?.ProxyClient.Connection.SslProtocol ?? SslProtocols.None;
......@@ -234,8 +234,8 @@ namespace Titanium.Web.Proxy.Network.Tcp
/// <param name="cancellationToken">The cancellation token for this async task.</param>
/// <returns></returns>
private async Task<TcpServerConnection> createServerConnection(string remoteHostName, int remotePort,
Version httpVersion, bool isHttps, SslProtocols sslProtocol, List<SslApplicationProtocol> applicationProtocols, bool isConnect,
ProxyServer proxyServer, SessionEventArgsBase session, IPEndPoint upStreamEndPoint, ExternalProxy externalProxy,
Version httpVersion, bool isHttps, SslProtocols sslProtocol, List<SslApplicationProtocol>? applicationProtocols, bool isConnect,
ProxyServer proxyServer, SessionEventArgsBase? session, IPEndPoint upStreamEndPoint, ExternalProxy? externalProxy,
CancellationToken cancellationToken)
{
// deny connection to proxy end points to avoid infinite connection loop.
......@@ -482,7 +482,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
}
}
internal async Task Release(Task<TcpServerConnection> connectionCreateTask, bool closeServerConnection)
internal async Task Release(Task<TcpServerConnection>? connectionCreateTask, bool closeServerConnection)
{
if (connectionCreateTask != null)
{
......
using System;
using System.Net;
#if NETSTANDARD2_1
using System.Net.Security;
#endif
using System.Net.Sockets;
using System.Threading.Tasks;
using Titanium.Web.Proxy.Extensions;
......@@ -49,7 +47,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
/// <summary>
/// Http version
/// </summary>
internal Version Version { get; set; }
internal Version Version { get; set; } = HttpHeader.VersionUnknown;
private readonly TcpClient tcpClient;
......@@ -66,7 +64,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
/// <summary>
/// Server stream
/// </summary>
internal CustomBufferedStream Stream { get; set; }
internal CustomBufferedStream? Stream { get; set; }
/// <summary>
/// Last time this connection was used
......
//
//
// Nancy.Authentication.Ntlm.Protocol.Type3Message - Authentication
//
// Author:
......@@ -58,7 +58,7 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
/// <summary>
/// Username
/// </summary>
internal string Username { get; private set; }
internal string? Username { get; private set; }
internal Common.NtlmFlags Flags { get; set; }
......
......@@ -128,7 +128,7 @@ namespace Titanium.Web.Proxy
if (!string.IsNullOrWhiteSpace(continuation))
{
return createContinuationResponse(response, continuation);
return createContinuationResponse(response, continuation!);
}
if (ProxyBasicAuthenticateFunc != null)
......
......@@ -115,7 +115,7 @@ namespace Titanium.Web.Proxy
/// <summary>
/// Manage system proxy settings.
/// </summary>
private SystemProxyManager systemProxySettingsManager { get; }
private SystemProxyManager? systemProxySettingsManager { get; }
/// <summary>
/// Number of exception retries when connection pool is enabled.
......@@ -249,18 +249,18 @@ namespace Titanium.Web.Proxy
/// <summary>
/// External proxy used for Http requests.
/// </summary>
public ExternalProxy UpStreamHttpProxy { get; set; }
public ExternalProxy? UpStreamHttpProxy { get; set; }
/// <summary>
/// External proxy used for Https requests.
/// </summary>
public ExternalProxy UpStreamHttpsProxy { get; set; }
public ExternalProxy? UpStreamHttpsProxy { get; set; }
/// <summary>
/// Local adapter/NIC endpoint where proxy makes request via.
/// Defaults via any IP addresses of this machine.
/// </summary>
public IPEndPoint UpStreamEndPoint { get; set; }
public IPEndPoint? UpStreamEndPoint { get; set; }
/// <summary>
/// A list of IpAddress and port this proxy is listening to.
......@@ -271,7 +271,7 @@ namespace Titanium.Web.Proxy
/// A callback to provide authentication credentials for up stream proxy this proxy is using for HTTP(S) requests.
/// User should return the ExternalProxy object with valid credentials.
/// </summary>
public Func<SessionEventArgsBase, Task<ExternalProxy>> GetCustomUpStreamProxyFunc { get; set; }
public Func<SessionEventArgsBase, Task<ExternalProxy?>>? GetCustomUpStreamProxyFunc { get; set; }
/// <summary>
/// Callback for error events in this proxy instance.
......@@ -344,12 +344,12 @@ namespace Titanium.Web.Proxy
/// <summary>
/// Customize TcpClient used for client connection upon create.
/// </summary>
public event AsyncEventHandler<TcpClient> OnClientConnectionCreate;
public event AsyncEventHandler<TcpClient>? OnClientConnectionCreate;
/// <summary>
/// Customize TcpClient used for server connection upon create.
/// </summary>
public event AsyncEventHandler<TcpClient> OnServerConnectionCreate;
public event AsyncEventHandler<TcpClient>? OnServerConnectionCreate;
/// <summary>
/// Customize the minimum ThreadPool size (increase it on a server)
......@@ -706,7 +706,7 @@ namespace Titanium.Web.Proxy
/// </summary>
/// <param name="sessionEventArgs">The session.</param>
/// <returns>The external proxy as task result.</returns>
private Task<ExternalProxy> getSystemUpStreamProxy(SessionEventArgsBase sessionEventArgs)
private Task<ExternalProxy?> getSystemUpStreamProxy(SessionEventArgsBase sessionEventArgs)
{
var proxy = systemProxyResolver.GetProxy(sessionEventArgs.HttpClient.Request.RequestUri);
return Task.FromResult(proxy);
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
#if NETSTANDARD2_1
using System.Net.Security;
#endif
using System.Net.Sockets;
using System.Threading;
using System.Threading.Tasks;
using Titanium.Web.Proxy.EventArguments;
......@@ -84,8 +82,7 @@ namespace Titanium.Web.Proxy
{
try
{
Request.ParseRequestLine(httpCmd, out string httpMethod, out string httpUrl,
out var version);
Request.ParseRequestLine(httpCmd, out string httpMethod, out string httpUrl, out var version);
// Read the request headers in to unique and non-unique header collections
await HeaderParser.ReadHeaders(clientStream, args.HttpClient.Request.Headers,
......@@ -224,7 +221,7 @@ namespace Titanium.Web.Proxy
closeServerConnection = !result.Continue;
// throw if exception happened
if (!result.IsSuccess)
if (result.Exception != null)
{
throw result.Exception;
}
......@@ -347,7 +344,6 @@ namespace Titanium.Web.Proxy
var clientStreamWriter = args.ProxyClient.ClientStreamWriter;
var response = args.HttpClient.Response;
var headerBuilder = new HeaderBuilder();
headerBuilder.WriteResponseLine(response.HttpVersion, response.StatusCode, response.StatusDescription);
headerBuilder.WriteHeaders(response.Headers);
......@@ -362,12 +358,12 @@ namespace Titanium.Web.Proxy
if (request.IsBodyRead)
{
var writer = args.HttpClient.Connection.StreamWriter;
await writer.WriteBodyAsync(body, request.IsChunked, cancellationToken);
await writer.WriteBodyAsync(body!, request.IsChunked, cancellationToken);
}
else if (!request.ExpectationFailed)
{
// get the request body unless an unsuccessful 100 continue request was made
HttpWriter writer = args.HttpClient.Connection.StreamWriter;
HttpWriter writer = args.HttpClient.Connection.StreamWriter!;
await args.CopyRequestBodyAsync(writer, TransformationMode.None, cancellationToken);
}
}
......
......@@ -37,7 +37,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
this.bufferPool = bufferPool;
}
public async Task<bool> FillBufferAsync(CancellationToken cancellationToken = default)
public async ValueTask<bool> FillBufferAsync(CancellationToken cancellationToken = default)
{
await FlushAsync(cancellationToken);
return await reader.FillBufferAsync(cancellationToken);
......@@ -124,7 +124,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
return result;
}
public Task<string> ReadLineAsync(CancellationToken cancellationToken = default)
public Task<string?> ReadLineAsync(CancellationToken cancellationToken = default)
{
return CustomBufferedStream.ReadLineInternalAsync(this, bufferPool, cancellationToken);
}
......
......@@ -69,7 +69,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// Fills the buffer asynchronous.
/// </summary>
/// <returns></returns>
Task<bool> ICustomStreamReader.FillBufferAsync(CancellationToken cancellationToken)
ValueTask<bool> ICustomStreamReader.FillBufferAsync(CancellationToken cancellationToken)
{
return baseStream.FillBufferAsync(cancellationToken);
}
......@@ -141,7 +141,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<string> ICustomStreamReader.ReadLineAsync(CancellationToken cancellationToken)
Task<string?> ICustomStreamReader.ReadLineAsync(CancellationToken cancellationToken)
{
return CustomBufferedStream.ReadLineInternalAsync(this, bufferPool, cancellationToken);
}
......
......@@ -36,9 +36,9 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
private readonly IBufferPool bufferPool;
public event EventHandler<DataEventArgs> DataRead;
public event EventHandler<DataEventArgs>? DataRead;
public event EventHandler<DataEventArgs> DataWrite;
public event EventHandler<DataEventArgs>? DataWrite;
public Stream BaseStream { get; }
......@@ -510,7 +510,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
public async Task<bool> FillBufferAsync(CancellationToken cancellationToken = default)
public async ValueTask<bool> FillBufferAsync(CancellationToken cancellationToken = default)
{
if (closed)
{
......@@ -558,7 +558,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// Read a line from the byte stream
/// </summary>
/// <returns></returns>
public Task<string> ReadLineAsync(CancellationToken cancellationToken = default)
public Task<string?> ReadLineAsync(CancellationToken cancellationToken = default)
{
return ReadLineInternalAsync(this, bufferPool, cancellationToken);
}
......
......@@ -17,7 +17,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// Fills the buffer asynchronous.
/// </summary>
/// <returns></returns>
Task<bool> FillBufferAsync(CancellationToken cancellationToken = default);
ValueTask<bool> FillBufferAsync(CancellationToken cancellationToken = default);
/// <summary>
/// Peeks a byte from buffer.
......@@ -74,6 +74,6 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
/// Read a line from the byte stream
/// </summary>
/// <returns></returns>
Task<string> ReadLineAsync(CancellationToken cancellationToken = default);
Task<string?> ReadLineAsync(CancellationToken cancellationToken = default);
}
}
......@@ -17,6 +17,7 @@
<PackageReference Include="Portable.BouncyCastle" Version="1.8.5" />
<PackageReference Include="System.Buffers" Version="4.5.0" />
<PackageReference Include="System.Memory" Version="4.5.3" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.3" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
......
......@@ -111,7 +111,7 @@ namespace Titanium.Web.Proxy
// initial value will match exactly any of the schemes
if (scheme != null)
{
string clientToken = WinAuthHandler.GetInitialAuthToken(request.Host, scheme, args.HttpClient.Data);
string clientToken = WinAuthHandler.GetInitialAuthToken(request.Host!, scheme, args.HttpClient.Data);
string auth = string.Concat(scheme, clientToken);
......@@ -127,7 +127,6 @@ namespace Titanium.Web.Proxy
else
{
// challenge value will start with any of the scheme selected
scheme = authSchemes.First(x =>
authHeader.Value.StartsWith(x, StringComparison.OrdinalIgnoreCase) &&
authHeader.Value.Length > x.Length + 1);
......
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