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