Commit 95c4cecf authored by justcoding121's avatar justcoding121

add descriptions to public API metadata

parent 24ef50c1
......@@ -12,7 +12,7 @@ namespace Titanium.Web.Proxy.Compression
private static readonly ICompression gzip = new GZipCompression();
private static readonly ICompression deflate = new DeflateCompression();
public static ICompression GetCompression(string type)
internal static ICompression GetCompression(string type)
{
switch (type)
{
......
......@@ -13,7 +13,7 @@ namespace Titanium.Web.Proxy.Decompression
private static readonly IDecompression deflate = new DeflateDecompression();
public static IDecompression Create(string type)
internal static IDecompression Create(string type)
{
switch (type)
{
......
......@@ -3,9 +3,9 @@
namespace Titanium.Web.Proxy.EventArguments
{
/// <summary>
/// A generic asynchronous event handler used by this proxy.
/// A generic asynchronous event handler used by the proxy.
/// </summary>
/// <typeparam name="TEventArgs"></typeparam>
/// <typeparam name="TEventArgs">Event argument type.</typeparam>
/// <param name="sender">The proxy server instance.</param>
/// <param name="e">The event arguments.</param>
/// <returns></returns>
......
......@@ -16,7 +16,7 @@ namespace Titanium.Web.Proxy.EventArguments
}
/// <summary>
/// The server name indication hostname.
/// The server name indication hostname if available. Otherwise the generic certificate hostname of TransparentEndPoint.
/// </summary>
public string SniHostName { get; internal set; }
......@@ -28,7 +28,7 @@ namespace Titanium.Web.Proxy.EventArguments
public bool DecryptSsl { get; set; } = true;
/// <summary>
/// Terminate the request abruptly.
/// Terminate the request abruptly by closing client/server connections.
/// </summary>
public void TerminateSession()
{
......
......@@ -14,27 +14,27 @@ namespace Titanium.Web.Proxy.EventArguments
public object Sender { get; internal set; }
/// <summary>
/// The host to which we are authenticating against.
/// The remote hostname to which we are authenticating against.
/// </summary>
public string TargetHost { get; internal set; }
/// <summary>
/// Local certificates with matching issuers.
/// Local certificates in store with matching issuers requested by TargetHost website.
/// </summary>
public X509CertificateCollection LocalCertificates { get; internal set; }
/// <summary>
/// Remote certificate of the server.
/// Certificate of the remote server.
/// </summary>
public X509Certificate RemoteCertificate { get; internal set; }
/// <summary>
/// Acceptable issuers mentioned by server.
/// Acceptable issuers as listed by remoted server.
/// </summary>
public string[] AcceptableIssuers { get; internal set; }
/// <summary>
/// Client Certificate we selected.
/// Client Certificate we selected. Set this value to override.
/// </summary>
public X509Certificate ClientCertificate { get; set; }
}
......
......@@ -26,7 +26,7 @@ namespace Titanium.Web.Proxy.EventArguments
public SslPolicyErrors SslPolicyErrors { get; internal set; }
/// <summary>
/// Is the given server certificate is valid?
/// Is the given server certificate valid?
/// </summary>
public bool IsValid { get; set; }
}
......
......@@ -20,12 +20,12 @@ namespace Titanium.Web.Proxy.EventArguments
public byte[] Buffer { get; }
/// <summary>
/// Offset in Buffer where valid data begins.
/// Offset in buffer from which valid data begins.
/// </summary>
public int Offset { get; }
/// <summary>
/// Length from offset in Buffer with valid data.
/// Length from offset in buffer with valid data.
/// </summary>
public int Count { get; }
}
......
......@@ -54,7 +54,7 @@ namespace Titanium.Web.Proxy.EventArguments
readChunkTrail = true;
string chunkHead = baseReader.ReadLineAsync().Result;
int idx = chunkHead.IndexOf(";");
int idx = chunkHead.IndexOf(";", StringComparison.Ordinal);
if (idx >= 0)
{
chunkHead = chunkHead.Substring(0, idx);
......@@ -68,7 +68,7 @@ namespace Titanium.Web.Proxy.EventArguments
bytesRemaining = -1;
//chunk trail
string s = baseReader.ReadLineAsync().Result;
baseReader.ReadLineAsync().Wait();
}
}
......
......@@ -8,14 +8,14 @@ namespace Titanium.Web.Proxy.EventArguments
/// </summary>
public class MultipartRequestPartSentEventArgs : EventArgs
{
public MultipartRequestPartSentEventArgs(string boundary, HeaderCollection headers)
internal MultipartRequestPartSentEventArgs(string boundary, HeaderCollection headers)
{
Boundary = boundary;
Headers = headers;
}
/// <summary>
/// Boundary
/// Boundary.
/// </summary>
public string Boundary { get; }
......
......@@ -348,7 +348,7 @@ namespace Titanium.Web.Proxy.EventArguments
/// <summary>
/// Gets the request body as bytes.
/// </summary>
/// <param name="cancellationToken"></param>
/// <param name="cancellationToken">Optional cancellation token for this async task.</param>
/// <returns>The body as bytes.</returns>
public async Task<byte[]> GetRequestBody(CancellationToken cancellationToken = default)
{
......@@ -363,7 +363,7 @@ namespace Titanium.Web.Proxy.EventArguments
/// <summary>
/// Gets the request body as string.
/// </summary>
/// <param name="cancellationToken">Cancellation token for this async task is optional.</param>
/// <param name="cancellationToken">Optional cancellation token for this async task.</param>
/// <returns>The body as string.</returns>
public async Task<string> GetRequestBodyAsString(CancellationToken cancellationToken = default)
{
......@@ -404,10 +404,12 @@ namespace Titanium.Web.Proxy.EventArguments
SetRequestBody(WebSession.Request.Encoding.GetBytes(body));
}
/// <summary>
/// Gets the response body as bytes.
/// </summary>
/// <returns></returns>
/// <param name="cancellationToken">Optional cancellation token for this async task.</param>
/// <returns>The resulting bytes.</returns>
public async Task<byte[]> GetResponseBody(CancellationToken cancellationToken = default)
{
if (!WebSession.Response.IsBodyRead)
......@@ -421,6 +423,7 @@ namespace Titanium.Web.Proxy.EventArguments
/// <summary>
/// Gets the response body as string.
/// </summary>
/// <param name="cancellationToken">Optional cancellation token for this async task.</param>
/// <returns>The string body.</returns>
public async Task<string> GetResponseBodyAsString(CancellationToken cancellationToken = default)
{
......@@ -435,7 +438,7 @@ namespace Titanium.Web.Proxy.EventArguments
/// <summary>
/// Set the response body bytes.
/// </summary>
/// <param name="body"></param>
/// <param name="body">The body bytes to set.</param>
public void SetResponseBody(byte[] body)
{
if (!WebSession.Request.Locked)
......@@ -450,7 +453,7 @@ namespace Titanium.Web.Proxy.EventArguments
/// <summary>
/// Replace the response body with the specified string.
/// </summary>
/// <param name="body"></param>
/// <param name="body">The body string to set.</param>
public void SetResponseBodyString(string body)
{
if (!WebSession.Request.Locked)
......@@ -467,8 +470,8 @@ namespace Titanium.Web.Proxy.EventArguments
/// Before request is made to server respond with the specified HTML string to client
/// and ignore the request.
/// </summary>
/// <param name="html"></param>
/// <param name="headers"></param>
/// <param name="html">HTML content to sent.</param>
/// <param name="headers">HTTP response headers.</param>
public void Ok(string html, Dictionary<string, HttpHeader> headers = null)
{
var response = new OkResponse();
......@@ -487,8 +490,8 @@ namespace Titanium.Web.Proxy.EventArguments
/// Before request is made to server respond with the specified byte[] to client
/// and ignore the request.
/// </summary>
/// <param name="result"></param>
/// <param name="headers"></param>
/// <param name="result">The html content bytes.</param>
/// <param name="headers">The HTTP headers.</param>
public void Ok(byte[] result, Dictionary<string, HttpHeader> headers = null)
{
var response = new OkResponse();
......@@ -504,9 +507,9 @@ namespace Titanium.Web.Proxy.EventArguments
/// respond with the specified HTML string and the specified status to client.
/// And then ignore the request. 
/// </summary>
/// <param name="html"></param>
/// <param name="status"></param>
/// <param name="headers"></param>
/// <param name="html">The html content.</param>
/// <param name="status">The HTTP status code.</param>
/// <param name="headers">The HTTP headers.</param>
/// <returns></returns>
public void GenericResponse(string html, HttpStatusCode status, Dictionary<string, HttpHeader> headers = null)
{
......@@ -522,9 +525,9 @@ namespace Titanium.Web.Proxy.EventArguments
/// Before request is made to server respond with the specified byte[],
/// the specified status to client. And then ignore the request.
/// </summary>
/// <param name="result"></param>
/// <param name="status"></param>
/// <param name="headers"></param>
/// <param name="result">The bytes to sent.</param>
/// <param name="status">The HTTP status code.</param>
/// <param name="headers">The HTTP headers.</param>
/// <returns></returns>
public void GenericResponse(byte[] result, HttpStatusCode status, Dictionary<string, HttpHeader> headers)
{
......@@ -539,7 +542,7 @@ namespace Titanium.Web.Proxy.EventArguments
/// <summary>
/// Redirect to provided URL.
/// </summary>
/// <param name="url"></param>
/// <param name="url">The URL to redirect.</param>
/// <returns></returns>
public void Redirect(string url)
{
......@@ -551,7 +554,10 @@ namespace Titanium.Web.Proxy.EventArguments
Respond(response);
}
/// a generic responder method
/// <summary>
/// Respond with given response object to client.
/// </summary>
/// <param name="response">The response object.</param>
public void Respond(Response response)
{
if (WebSession.Request.Locked)
......@@ -576,13 +582,16 @@ namespace Titanium.Web.Proxy.EventArguments
}
}
/// <summary>
/// Terminate the connection to server.
/// </summary>
public void TerminateServerConnection()
{
WebSession.Response.TerminateResponse = true;
}
/// <summary>
/// implement any cleanup here
/// Implement any cleanup here
/// </summary>
public override void Dispose()
{
......
......@@ -9,10 +9,10 @@ using Titanium.Web.Proxy.Network;
namespace Titanium.Web.Proxy.EventArguments
{
/// <summary>
/// Holds info related to a single proxy session (single request/response sequence)
/// A proxy session is bounded to a single connection from client
/// Holds info related to a single proxy session (single request/response sequence).
/// A proxy session is bounded to a single connection from client.
/// A proxy session ends when client terminates connection to proxy
/// or when server terminates connection from proxy
/// or when server terminates connection from proxy.
/// </summary>
public abstract class SessionEventArgsBase : EventArgs, IDisposable
{
......@@ -73,13 +73,13 @@ namespace Titanium.Web.Proxy.EventArguments
internal ProxyClient ProxyClient { get; }
/// <summary>
/// Returns a unique Id for this request/response session
/// same as RequestId of WebSession
/// Returns a unique Id for this request/response session which is
/// same as the RequestId of WebSession.
/// </summary>
public Guid Id => WebSession.RequestId;
/// <summary>
/// Does this session uses SSL
/// Does this session uses SSL?
/// </summary>
public bool IsHttps => WebSession.Request.IsHttps;
......@@ -90,7 +90,7 @@ namespace Titanium.Web.Proxy.EventArguments
/// <summary>
/// A web session corresponding to a single request/response sequence
/// within a proxy connection
/// within a proxy connection.
/// </summary>
public HttpWebClient WebSession { get; }
......@@ -99,14 +99,23 @@ namespace Titanium.Web.Proxy.EventArguments
/// </summary>
public ExternalProxy CustomUpStreamProxyUsed { get; internal set; }
/// <summary>
/// Local endpoint via which we make the request.
/// </summary>
public ProxyEndPoint LocalEndPoint { get; }
/// <summary>
/// Is this a transparent endpoint?
/// </summary>
public bool IsTransparent => LocalEndPoint is TransparentProxyEndPoint;
/// <summary>
/// The last exception that happened.
/// </summary>
public Exception Exception { get; internal set; }
/// <summary>
/// implement any cleanup here
/// Implements cleanup here.
/// </summary>
public virtual void Dispose()
{
......@@ -119,8 +128,14 @@ namespace Titanium.Web.Proxy.EventArguments
WebSession.FinishSession();
}
/// <summary>
/// Fired when data is sent within this session to server/client.
/// </summary>
public event EventHandler<DataEventArgs> DataSent;
/// <summary>
/// Fired when data is received within this session from client/server.
/// </summary>
public event EventHandler<DataEventArgs> DataReceived;
internal void OnDataSent(byte[] buffer, int offset, int count)
......@@ -148,7 +163,7 @@ namespace Titanium.Web.Proxy.EventArguments
}
/// <summary>
/// Terminates the session abruptly by terminating client/server connections
/// Terminates the session abruptly by terminating client/server connections.
/// </summary>
public void TerminateSession()
{
......
......@@ -5,6 +5,9 @@ using Titanium.Web.Proxy.Models;
namespace Titanium.Web.Proxy.EventArguments
{
/// <summary>
/// A class that wraps the state when a tunnel connect event happen for Explicit endpoints.
/// </summary>
public class TunnelConnectSessionEventArgs : SessionEventArgsBase
{
private bool? isHttpsConnect;
......@@ -16,13 +19,20 @@ namespace Titanium.Web.Proxy.EventArguments
WebSession.ConnectRequest = connectRequest;
}
/// <summary>
/// Should we decrypt the Ssl or relay it to server?
/// Default is true.
/// </summary>
public bool DecryptSsl { get; set; } = true;
/// <summary>
/// Denies the connect request with a Forbidden status
/// When set to true it denies the connect request with a Forbidden status.
/// </summary>
public bool DenyConnect { get; set; }
/// <summary>
/// Is this a connect request to secure HTTP server? Or is it to someother protocol.
/// </summary>
public bool IsHttpsConnect
{
get => isHttpsConnect ?? throw new Exception("The value of this property is known in the BeforeTunnectConnectResponse event");
......
namespace Titanium.Web.Proxy.Exceptions
{
/// <summary>
/// An expception thrown when body is unexpectedly empty
/// An exception thrown when body is unexpectedly empty.
/// </summary>
public class BodyNotFoundException : ProxyException
{
......
......@@ -6,14 +6,14 @@ using Titanium.Web.Proxy.Models;
namespace Titanium.Web.Proxy.Exceptions
{
/// <summary>
/// Proxy authorization exception
/// Proxy authorization exception.
/// </summary>
public class ProxyAuthorizationException : ProxyException
{
/// <summary>
/// Instantiate new instance
/// Instantiate new instance.
/// </summary>
/// <param name="message">Exception message</param>
/// <param name="message">Exception message.</param>
/// <param name="session">The <see cref="SessionEventArgs" /> instance containing the event data.</param>
/// <param name="innerException">Inner exception associated to upstream proxy authorization</param>
/// <param name="headers">Http's headers associated</param>
......@@ -24,10 +24,13 @@ namespace Titanium.Web.Proxy.Exceptions
Headers = headers;
}
/// <summary>
/// The current session within which this error happened.
/// </summary>
public SessionEventArgsBase Session { get; }
/// <summary>
/// Headers associated with the authorization exception
/// Headers associated with the authorization exception.
/// </summary>
public IEnumerable<HttpHeader> Headers { get; }
}
......
......@@ -3,7 +3,7 @@
namespace Titanium.Web.Proxy.Exceptions
{
/// <summary>
/// Base class exception associated with this proxy implementation
/// Base class exception associated with this proxy server.
/// </summary>
public abstract class ProxyException : Exception
{
......
......@@ -4,7 +4,7 @@ using Titanium.Web.Proxy.EventArguments;
namespace Titanium.Web.Proxy.Exceptions
{
/// <summary>
/// Proxy HTTP exception
/// Proxy HTTP exception.
/// </summary>
public class ProxyHttpException : ProxyException
{
......@@ -21,10 +21,10 @@ namespace Titanium.Web.Proxy.Exceptions
}
/// <summary>
/// Gets session info associated to the exception
/// Gets session info associated to the exception.
/// </summary>
/// <remarks>
/// This object should not be edited
/// This object properties should not be edited.
/// </remarks>
public SessionEventArgs SessionEventArgs { get; }
}
......
......@@ -6,14 +6,14 @@ namespace Titanium.Web.Proxy.Extensions
{
internal static class FuncExtensions
{
public static async Task InvokeAsync<T>(this AsyncEventHandler<T> callback, object sender, T args,
internal static async Task InvokeAsync<T>(this AsyncEventHandler<T> callback, object sender, T args,
ExceptionHandler exceptionFunc)
{
var invocationList = callback.GetInvocationList();
for (int i = 0; i < invocationList.Length; i++)
foreach (var @delegate in invocationList)
{
await InternalInvokeAsync((AsyncEventHandler<T>)invocationList[i], sender, args, exceptionFunc);
await InternalInvokeAsync((AsyncEventHandler<T>)@delegate, sender, args, exceptionFunc);
}
}
......
......@@ -13,9 +13,9 @@ namespace Titanium.Web.Proxy.Extensions
{
internal static class SslExtensions
{
public static readonly List<SslApplicationProtocol> Http11ProtocolAsList = new List<SslApplicationProtocol> { SslApplicationProtocol.Http11 };
internal static readonly List<SslApplicationProtocol> Http11ProtocolAsList = new List<SslApplicationProtocol> { SslApplicationProtocol.Http11 };
public static string GetServerName(this ClientHelloInfo clientHelloInfo)
internal static string GetServerName(this ClientHelloInfo clientHelloInfo)
{
if (clientHelloInfo.Extensions != null &&
clientHelloInfo.Extensions.TryGetValue("server_name", out var serverNameExtension))
......@@ -27,7 +27,7 @@ namespace Titanium.Web.Proxy.Extensions
}
#if NETCOREAPP2_1
public static List<SslApplicationProtocol> GetAlpn(this ClientHelloInfo clientHelloInfo)
internal static List<SslApplicationProtocol> GetAlpn(this ClientHelloInfo clientHelloInfo)
{
if (clientHelloInfo.Extensions != null && clientHelloInfo.Extensions.TryGetValue("ALPN", out var alpnExtension))
{
......@@ -55,17 +55,17 @@ namespace Titanium.Web.Proxy.Extensions
return null;
}
#else
public static List<SslApplicationProtocol> GetAlpn(this ClientHelloInfo clientHelloInfo)
internal static List<SslApplicationProtocol> GetAlpn(this ClientHelloInfo clientHelloInfo)
{
return Http11ProtocolAsList;
}
public static Task AuthenticateAsClientAsync(this SslStream sslStream, SslClientAuthenticationOptions option, CancellationToken token)
internal static Task AuthenticateAsClientAsync(this SslStream sslStream, SslClientAuthenticationOptions option, CancellationToken token)
{
return sslStream.AuthenticateAsClientAsync(option.TargetHost, option.ClientCertificates, option.EnabledSslProtocols, option.CertificateRevocationCheckMode != X509RevocationMode.NoCheck);
}
public static Task AuthenticateAsServerAsync(this SslStream sslStream, SslServerAuthenticationOptions options, CancellationToken token)
internal static Task AuthenticateAsServerAsync(this SslStream sslStream, SslServerAuthenticationOptions options, CancellationToken token)
{
return sslStream.AuthenticateAsServerAsync(options.ServerCertificate, options.ClientCertificateRequired, options.EnabledSslProtocols, options.CertificateRevocationCheckMode != X509RevocationMode.NoCheck);
}
......@@ -73,49 +73,49 @@ namespace Titanium.Web.Proxy.Extensions
}
#if !NETCOREAPP2_1
public enum SslApplicationProtocol
internal enum SslApplicationProtocol
{
Http11, Http2
}
public class SslClientAuthenticationOptions
internal class SslClientAuthenticationOptions
{
public bool AllowRenegotiation { get; set; }
internal bool AllowRenegotiation { get; set; }
public string TargetHost { get; set; }
internal string TargetHost { get; set; }
public X509CertificateCollection ClientCertificates { get; set; }
internal X509CertificateCollection ClientCertificates { get; set; }
public LocalCertificateSelectionCallback LocalCertificateSelectionCallback { get; set; }
internal LocalCertificateSelectionCallback LocalCertificateSelectionCallback { get; set; }
public SslProtocols EnabledSslProtocols { get; set; }
internal SslProtocols EnabledSslProtocols { get; set; }
public X509RevocationMode CertificateRevocationCheckMode { get; set; }
internal X509RevocationMode CertificateRevocationCheckMode { get; set; }
public List<SslApplicationProtocol> ApplicationProtocols { get; set; }
internal List<SslApplicationProtocol> ApplicationProtocols { get; set; }
public RemoteCertificateValidationCallback RemoteCertificateValidationCallback { get; set; }
internal RemoteCertificateValidationCallback RemoteCertificateValidationCallback { get; set; }
public EncryptionPolicy EncryptionPolicy { get; set; }
internal EncryptionPolicy EncryptionPolicy { get; set; }
}
public class SslServerAuthenticationOptions
internal class SslServerAuthenticationOptions
{
public bool AllowRenegotiation { get; set; }
internal bool AllowRenegotiation { get; set; }
public X509Certificate ServerCertificate { get; set; }
internal X509Certificate ServerCertificate { get; set; }
public bool ClientCertificateRequired { get; set; }
internal bool ClientCertificateRequired { get; set; }
public SslProtocols EnabledSslProtocols { get; set; }
internal SslProtocols EnabledSslProtocols { get; set; }
public X509RevocationMode CertificateRevocationCheckMode { get; set; }
internal X509RevocationMode CertificateRevocationCheckMode { get; set; }
public List<SslApplicationProtocol> ApplicationProtocols { get; set; }
internal List<SslApplicationProtocol> ApplicationProtocols { get; set; }
public RemoteCertificateValidationCallback RemoteCertificateValidationCallback { get; set; }
internal RemoteCertificateValidationCallback RemoteCertificateValidationCallback { get; set; }
public EncryptionPolicy EncryptionPolicy { get; set; }
internal EncryptionPolicy EncryptionPolicy { get; set; }
}
#endif
}
......@@ -7,18 +7,18 @@ namespace Titanium.Web.Proxy.Helpers
{
internal sealed class HttpRequestWriter : HttpWriter
{
public HttpRequestWriter(Stream stream, int bufferSize) : base(stream, bufferSize)
internal HttpRequestWriter(Stream stream, int bufferSize) : base(stream, bufferSize)
{
}
/// <summary>
/// Writes the request.
/// </summary>
/// <param name="request"></param>
/// <param name="flush"></param>
/// <param name="cancellationToken"></param>
/// <param name="request">The request object.</param>
/// <param name="flush">Should we flush after write?</param>
/// <param name="cancellationToken">Optional cancellation token for this async task.</param>
/// <returns></returns>
public async Task WriteRequestAsync(Request request, bool flush = true,
internal async Task WriteRequestAsync(Request request, bool flush = true,
CancellationToken cancellationToken = default)
{
await WriteLineAsync(Request.CreateRequestLine(request.Method, request.OriginalUrl, request.HttpVersion),
......
......@@ -8,18 +8,18 @@ namespace Titanium.Web.Proxy.Helpers
{
internal sealed class HttpResponseWriter : HttpWriter
{
public HttpResponseWriter(Stream stream, int bufferSize) : base(stream, bufferSize)
internal HttpResponseWriter(Stream stream, int bufferSize) : base(stream, bufferSize)
{
}
/// <summary>
/// Writes the response.
/// </summary>
/// <param name="response"></param>
/// <param name="flush"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task WriteResponseAsync(Response response, bool flush = true,
/// <param name="response">The response object.</param>
/// <param name="flush">Should we flush after write?</param>
/// <param name="cancellationToken">Optional cancellation token for this async task.</param>
/// <returns>The Task.</returns>
internal async Task WriteResponseAsync(Response response, bool flush = true,
CancellationToken cancellationToken = default)
{
await WriteResponseStatusAsync(response.HttpVersion, response.StatusCode, response.StatusDescription,
......@@ -30,12 +30,12 @@ namespace Titanium.Web.Proxy.Helpers
/// <summary>
/// Write response status
/// </summary>
/// <param name="version"></param>
/// <param name="code"></param>
/// <param name="description"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public Task WriteResponseStatusAsync(Version version, int code, string description, CancellationToken cancellationToken)
/// <param name="version">The Http version.</param>
/// <param name="code">The HTTP status code.</param>
/// <param name="description">The HTTP status description.</param>
/// <param name="cancellationToken">Optional cancellation token for this async task.</param>
/// <returns>The Task.</returns>
internal Task WriteResponseStatusAsync(Version version, int code, string description, CancellationToken cancellationToken)
{
return WriteLineAsync(Response.CreateResponseLine(version, code, description), cancellationToken);
}
......
......@@ -27,14 +27,19 @@ namespace Titanium.Web.Proxy.Helpers
charBuffer = new char[BufferSize - 1];
}
public int BufferSize { get; }
internal int BufferSize { get; }
public Task WriteLineAsync(CancellationToken cancellationToken = default)
/// <summary>
/// Writes a line async
/// </summary>
/// <param name="cancellationToken">Optional cancellation token for this async task.</param>
/// <returns></returns>
internal Task WriteLineAsync(CancellationToken cancellationToken = default)
{
return WriteAsync(newLine, cancellationToken: cancellationToken);
}
public Task WriteAsync(string value, CancellationToken cancellationToken = default)
internal Task WriteAsync(string value, CancellationToken cancellationToken = default)
{
return WriteAsyncInternal(value, false, cancellationToken);
}
......@@ -81,7 +86,7 @@ namespace Titanium.Web.Proxy.Helpers
}
}
public Task WriteLineAsync(string value, CancellationToken cancellationToken = default)
internal Task WriteLineAsync(string value, CancellationToken cancellationToken = default)
{
return WriteAsyncInternal(value, true, cancellationToken);
}
......@@ -93,7 +98,7 @@ namespace Titanium.Web.Proxy.Helpers
/// <param name="flush"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task WriteHeadersAsync(HeaderCollection headers, bool flush = true, CancellationToken cancellationToken = default)
internal async Task WriteHeadersAsync(HeaderCollection headers, bool flush = true, CancellationToken cancellationToken = default)
{
foreach (var header in headers)
{
......@@ -107,7 +112,7 @@ namespace Titanium.Web.Proxy.Helpers
}
}
public async Task WriteAsync(byte[] data, bool flush = false, CancellationToken cancellationToken = default)
internal async Task WriteAsync(byte[] data, bool flush = false, CancellationToken cancellationToken = default)
{
await WriteAsync(data, 0, data.Length, cancellationToken);
if (flush)
......@@ -116,7 +121,7 @@ namespace Titanium.Web.Proxy.Helpers
}
}
public async Task WriteAsync(byte[] data, int offset, int count, bool flush, CancellationToken cancellationToken = default)
internal async Task WriteAsync(byte[] data, int offset, int count, bool flush, CancellationToken cancellationToken = default)
{
await WriteAsync(data, offset, count, cancellationToken);
if (flush)
......
......@@ -8,7 +8,7 @@ namespace Titanium.Web.Proxy.Helpers
{
internal class ProxyInfo
{
public ProxyInfo(bool? autoDetect, string autoConfigUrl, int? proxyEnable, string proxyServer,
internal ProxyInfo(bool? autoDetect, string autoConfigUrl, int? proxyEnable, string proxyServer,
string proxyOverride)
{
AutoDetect = autoDetect;
......@@ -51,23 +51,23 @@ namespace Titanium.Web.Proxy.Helpers
}
}
public bool? AutoDetect { get; }
internal bool? AutoDetect { get; }
public string AutoConfigUrl { get; }
internal string AutoConfigUrl { get; }
public int? ProxyEnable { get; }
internal int? ProxyEnable { get; }
public string ProxyServer { get; }
internal string ProxyServer { get; }
public string ProxyOverride { get; }
internal string ProxyOverride { get; }
public bool BypassLoopback { get; }
internal bool BypassLoopback { get; }
public bool BypassOnLocal { get; }
internal bool BypassOnLocal { get; }
public Dictionary<ProxyProtocolType, HttpSystemProxyValue> Proxies { get; }
internal Dictionary<ProxyProtocolType, HttpSystemProxyValue> Proxies { get; }
public string[] BypassList { get; }
internal string[] BypassList { get; }
private static string BypassStringEscape(string rawString)
{
......@@ -131,7 +131,7 @@ namespace Titanium.Web.Proxy.Helpers
return stringBuilder.ToString();
}
public static ProxyProtocolType? ParseProtocolType(string protocolTypeStr)
internal static ProxyProtocolType? ParseProtocolType(string protocolTypeStr)
{
if (protocolTypeStr == null)
{
......@@ -157,7 +157,7 @@ namespace Titanium.Web.Proxy.Helpers
/// </summary>
/// <param name="proxyServerValues"></param>
/// <returns></returns>
public static List<HttpSystemProxyValue> GetSystemProxyValues(string proxyServerValues)
internal static List<HttpSystemProxyValue> GetSystemProxyValues(string proxyServerValues)
{
var result = new List<HttpSystemProxyValue>();
......
......@@ -27,12 +27,12 @@ namespace Titanium.Web.Proxy.Http
}
/// <summary>
/// Unique Request header collection
/// Unique Request header collection.
/// </summary>
public ReadOnlyDictionary<string, HttpHeader> Headers { get; }
/// <summary>
/// Non Unique headers
/// Non Unique headers.
/// </summary>
public ReadOnlyDictionary<string, List<HttpHeader>> NonUniqueHeaders { get; }
......
......@@ -15,12 +15,12 @@ namespace Titanium.Web.Proxy.Http
public class Request : RequestResponseBase
{
/// <summary>
/// Request Method
/// Request Method.
/// </summary>
public string Method { get; set; }
/// <summary>
/// Request HTTP Uri
/// Request HTTP Uri.
/// </summary>
public Uri RequestUri { get; set; }
......@@ -66,9 +66,9 @@ namespace Titanium.Web.Proxy.Http
}
/// <summary>
/// Http hostname header value if exists
/// Note: Changing this does NOT change host in RequestUri
/// Users can set new RequestUri separately
/// Http hostname header value if exists.
/// Note: Changing this does NOT change host in RequestUri.
/// Users can set new RequestUri separately.
/// </summary>
public string Host
{
......@@ -88,15 +88,18 @@ namespace Titanium.Web.Proxy.Http
}
}
/// <summary>
/// Does this request contain multipart/form-data?
/// </summary>
public bool IsMultipartFormData => ContentType?.StartsWith("multipart/form-data") == true;
/// <summary>
/// Request Url
/// Request Url.
/// </summary>
public string Url => RequestUri.OriginalString;
/// <summary>
/// Terminates the underlying Tcp Connection to client after current request
/// Terminates the underlying Tcp Connection to client after current request.
/// </summary>
internal bool CancelRequest { get; set; }
......@@ -119,12 +122,12 @@ namespace Titanium.Web.Proxy.Http
}
/// <summary>
/// Does server responsed positively for 100 continue request
/// Did server responsed positively for 100 continue request?
/// </summary>
public bool Is100Continue { get; internal set; }
/// <summary>
/// Server responsed negatively for the request for 100 continue
/// Did server responsed negatively for the request for 100 continue?
/// </summary>
public bool ExpectationFailed { get; internal set; }
......
......@@ -12,12 +12,12 @@ namespace Titanium.Web.Proxy.Http
public abstract class RequestResponseBase
{
/// <summary>
/// Cached body content as byte array
/// Cached body content as byte array.
/// </summary>
protected byte[] BodyInternal;
/// <summary>
/// Cached body as string
/// Cached body as string.
/// </summary>
private string bodyString;
......@@ -27,22 +27,22 @@ namespace Titanium.Web.Proxy.Http
internal bool OriginalHasBody;
/// <summary>
/// Keeps the body data after the session is finished
/// Keeps the body data after the session is finished.
/// </summary>
public bool KeepBody { get; set; }
/// <summary>
/// Http Version
/// Http Version.
/// </summary>
public Version HttpVersion { get; set; } = HttpHeader.VersionUnknown;
/// <summary>
/// Collection of all headers
/// Collection of all headers.
/// </summary>
public HeaderCollection Headers { get; } = new HeaderCollection();
/// <summary>
/// Length of the body
/// Length of the body.
/// </summary>
public long ContentLength
{
......@@ -77,17 +77,17 @@ namespace Titanium.Web.Proxy.Http
}
/// <summary>
/// Content encoding for this request/response
/// Content encoding for this request/response.
/// </summary>
public string ContentEncoding => Headers.GetHeaderValueOrNull(KnownHeaders.ContentEncoding)?.Trim();
/// <summary>
/// Encoding for this request/response
/// Encoding for this request/response.
/// </summary>
public Encoding Encoding => HttpHelper.GetEncodingFromContentType(ContentType);
/// <summary>
/// Content-type of the request/response
/// Content-type of the request/response.
/// </summary>
public string ContentType
{
......@@ -96,7 +96,7 @@ namespace Titanium.Web.Proxy.Http
}
/// <summary>
/// Is body send as chunked bytes
/// Is body send as chunked bytes.
/// </summary>
public bool IsChunked
{
......@@ -119,6 +119,9 @@ namespace Titanium.Web.Proxy.Http
}
}
/// <summary>
/// The header text.
/// </summary>
public abstract string HeaderText { get; }
/// <summary>
......@@ -148,7 +151,7 @@ namespace Titanium.Web.Proxy.Http
public abstract bool HasBody { get; }
/// <summary>
/// Body as string
/// Body as string.
/// Use the encoding specified to decode the byte[] data to string
/// </summary>
[Browsable(false)]
......
......@@ -7,17 +7,17 @@ using Titanium.Web.Proxy.Extensions;
namespace Titanium.Web.Proxy.Models
{
/// <summary>
/// A proxy endpoint that the client is aware of
/// So client application know that it is communicating with a proxy server
/// A proxy endpoint that the client is aware of.
/// So client application know that it is communicating with a proxy server.
/// </summary>
public class ExplicitProxyEndPoint : ProxyEndPoint
{
/// <summary>
/// Constructor.
/// Constructor.
/// </summary>
/// <param name="ipAddress"></param>
/// <param name="port"></param>
/// <param name="decryptSsl"></param>
/// <param name="ipAddress">Listening IP address.</param>
/// <param name="port">Listening port.</param>
/// <param name="decryptSsl">Should we decrypt ssl?</param>
public ExplicitProxyEndPoint(IPAddress ipAddress, int port, bool decryptSsl = true) : base(ipAddress, port,
decryptSsl)
{
......@@ -33,16 +33,16 @@ namespace Titanium.Web.Proxy.Models
public X509Certificate2 GenericCertificate { get; set; }
/// <summary>
/// Intercept tunnel connect request
/// Valid only for explicit endpoints
/// Intercept tunnel connect request.
/// Valid only for explicit endpoints.
/// Set the <see cref="TunnelConnectSessionEventArgs.DecryptSsl" /> property to false if this HTTP connect request
/// should'nt be decrypted and instead be relayed
/// should'nt be decrypted and instead be relayed.
/// </summary>
public event AsyncEventHandler<TunnelConnectSessionEventArgs> BeforeTunnelConnectRequest;
/// <summary>
/// Intercept tunnel connect response
/// Valid only for explicit endpoints
/// Intercept tunnel connect response.
/// Valid only for explicit endpoints.
/// </summary>
public event AsyncEventHandler<TunnelConnectSessionEventArgs> BeforeTunnelConnectResponse;
......
......@@ -4,7 +4,7 @@ using System.Net;
namespace Titanium.Web.Proxy.Models
{
/// <summary>
/// An upstream proxy this proxy uses if any
/// An upstream proxy this proxy uses if any.
/// </summary>
public class ExternalProxy
{
......@@ -69,6 +69,10 @@ namespace Titanium.Web.Proxy.Models
/// </summary>
public int Port { get; set; }
/// <summary>
/// returns data in Hostname:port format.
/// </summary>
/// <returns></returns>
public override string ToString()
{
return $"{HostName}:{Port}";
......
......@@ -22,12 +22,11 @@ namespace Titanium.Web.Proxy.Models
internal static readonly HttpHeader ProxyConnectionKeepAlive = new HttpHeader("Proxy-Connection", "keep-alive");
/// <summary>
/// Constructor.
/// </summary>
/// <param name="name"></param>
/// <param name="value"></param>
/// <exception cref="Exception"></exception>
/// <summary>
/// Initialize a new instance.
/// </summary>
/// <param name="name">Header name.</param>
/// <param name="value">Header value.</param>
public HttpHeader(string name, string value)
{
if (string.IsNullOrEmpty(name))
......@@ -50,7 +49,7 @@ namespace Titanium.Web.Proxy.Models
public string Value { get; set; }
/// <summary>
/// Returns header as a valid header string
/// Returns header as a valid header string.
/// </summary>
/// <returns></returns>
public override string ToString()
......
......@@ -6,17 +6,17 @@ using Titanium.Web.Proxy.Extensions;
namespace Titanium.Web.Proxy.Models
{
/// <summary>
/// A proxy end point client is not aware of
/// Usefull when requests are redirected to this proxy end point through port forwarding
/// A proxy end point client is not aware of.
/// Useful when requests are redirected to this proxy end point through port forwarding via router.
/// </summary>
public class TransparentProxyEndPoint : ProxyEndPoint
{
/// <summary>
/// Constructor.
/// Initialize a new instance.
/// </summary>
/// <param name="ipAddress"></param>
/// <param name="port"></param>
/// <param name="decryptSsl"></param>
/// <param name="ipAddress">Listening Ip address.</param>
/// <param name="port">Listening port.</param>
/// <param name="decryptSsl">Should we decrypt ssl?</param>
public TransparentProxyEndPoint(IPAddress ipAddress, int port, bool decryptSsl = true) : base(ipAddress, port,
decryptSsl)
{
......@@ -24,13 +24,13 @@ namespace Titanium.Web.Proxy.Models
}
/// <summary>
/// Name of the Certificate need to be sent (same as the hostname we want to proxy)
/// This is valid only when UseServerNameIndication is set to false
/// Name of the Certificate need to be sent (same as the hostname we want to proxy).
/// This is valid only when UseServerNameIndication is set to false.
/// </summary>
public string GenericCertificateName { get; set; }
/// <summary>
/// Before Ssl authentication
/// Before Ssl authentication this event is fired.
/// </summary>
public event AsyncEventHandler<BeforeSslAuthenticateEventArgs> BeforeSslAuthenticate;
......
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