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

Commit 348e1b3

Browse files
committed
Update documentation
1 parent fe9de69 commit 348e1b3

File tree

9 files changed

+156
-123
lines changed

9 files changed

+156
-123
lines changed

Titanium.Web.Proxy/EventArguments/AsyncEventHandler.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,12 @@
22

33
namespace Titanium.Web.Proxy.EventArguments
44
{
5+
/// <summary>
6+
/// A generic asynchronous event handler used by this proxy.
7+
/// </summary>
8+
/// <typeparam name="TEventArgs"></typeparam>
9+
/// <param name="sender">The proxy server instance.</param>
10+
/// <param name="e">The event arguments.</param>
11+
/// <returns></returns>
512
public delegate Task AsyncEventHandler<in TEventArgs>(object sender, TEventArgs e);
613
}

Titanium.Web.Proxy/EventArguments/BeforeSslAuthenticateEventArgs.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
namespace Titanium.Web.Proxy.EventArguments
55
{
6+
/// <summary>
7+
/// This is used in transparent endpoint before authenticating client.
8+
/// </summary>
69
public class BeforeSslAuthenticateEventArgs : EventArgs
710
{
811
internal readonly CancellationTokenSource TaskCancellationSource;
@@ -12,10 +15,21 @@ internal BeforeSslAuthenticateEventArgs(CancellationTokenSource taskCancellation
1215
TaskCancellationSource = taskCancellationSource;
1316
}
1417

18+
/// <summary>
19+
/// The server name indication hostname.
20+
/// </summary>
1521
public string SniHostName { get; internal set; }
1622

23+
/// <summary>
24+
/// Should we decrypt the SSL request?
25+
/// If true we decrypt with fake certificate.
26+
/// If false we relay the connection to the hostname mentioned in SniHostname.
27+
/// </summary>
1728
public bool DecryptSsl { get; set; } = true;
1829

30+
/// <summary>
31+
/// Terminate the request abruptly.
32+
/// </summary>
1933
public void TerminateSession()
2034
{
2135
TaskCancellationSource.Cancel();

Titanium.Web.Proxy/EventArguments/CertificateSelectionEventArgs.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,37 @@
44
namespace Titanium.Web.Proxy.EventArguments
55
{
66
/// <summary>
7-
/// An argument passed on to user for client certificate selection during mutual SSL authentication
7+
/// An argument passed on to user for client certificate selection during mutual SSL authentication.
88
/// </summary>
99
public class CertificateSelectionEventArgs : EventArgs
1010
{
1111
/// <summary>
12-
/// Sender object.
12+
/// The proxy server instance.
1313
/// </summary>
1414
public object Sender { get; internal set; }
1515

1616
/// <summary>
17-
/// Target host.
17+
/// The host to which we are authenticating against.
1818
/// </summary>
1919
public string TargetHost { get; internal set; }
2020

2121
/// <summary>
22-
/// Local certificates.
22+
/// Local certificates with matching issuers.
2323
/// </summary>
2424
public X509CertificateCollection LocalCertificates { get; internal set; }
2525

2626
/// <summary>
27-
/// Remote certificate.
27+
/// Remote certificate of the server.
2828
/// </summary>
2929
public X509Certificate RemoteCertificate { get; internal set; }
3030

3131
/// <summary>
32-
/// Acceptable issuers.
32+
/// Acceptable issuers mentioned by server.
3333
/// </summary>
3434
public string[] AcceptableIssuers { get; internal set; }
3535

3636
/// <summary>
37-
/// Client Certificate.
37+
/// Client Certificate we selected.
3838
/// </summary>
3939
public X509Certificate ClientCertificate { get; set; }
4040
}

Titanium.Web.Proxy/EventArguments/CertificateValidationEventArgs.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@
55
namespace Titanium.Web.Proxy.EventArguments
66
{
77
/// <summary>
8-
/// An argument passed on to the user for validating the server certificate during SSL authentication
8+
/// An argument passed on to the user for validating the server certificate
9+
/// during SSL authentication.
910
/// </summary>
1011
public class CertificateValidationEventArgs : EventArgs
1112
{
1213
/// <summary>
13-
/// Certificate
14+
/// Server certificate.
1415
/// </summary>
1516
public X509Certificate Certificate { get; internal set; }
1617

1718
/// <summary>
18-
/// Certificate chain
19+
/// Certificate chain.
1920
/// </summary>
2021
public X509Chain Chain { get; internal set; }
2122

@@ -25,7 +26,7 @@ public class CertificateValidationEventArgs : EventArgs
2526
public SslPolicyErrors SslPolicyErrors { get; internal set; }
2627

2728
/// <summary>
28-
/// is a valid certificate?
29+
/// Is the given server certificate is valid?
2930
/// </summary>
3031
public bool IsValid { get; set; }
3132
}

Titanium.Web.Proxy/EventArguments/DataEventArgs.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace Titanium.Web.Proxy.EventArguments
44
{
5+
/// <summary>
6+
/// Wraps the data sent/received by a proxy server instance.
7+
/// </summary>
58
public class DataEventArgs : EventArgs
69
{
710
internal DataEventArgs(byte[] buffer, int offset, int count)
@@ -11,10 +14,19 @@ internal DataEventArgs(byte[] buffer, int offset, int count)
1114
Count = count;
1215
}
1316

17+
/// <summary>
18+
/// The buffer with data.
19+
/// </summary>
1420
public byte[] Buffer { get; }
1521

22+
/// <summary>
23+
/// Offset in Buffer where valid data begins.
24+
/// </summary>
1625
public int Offset { get; }
1726

27+
/// <summary>
28+
/// Length from offset in Buffer with valid data.
29+
/// </summary>
1830
public int Count { get; }
1931
}
2032
}

Titanium.Web.Proxy/EventArguments/MultipartRequestPartSentEventArgs.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
namespace Titanium.Web.Proxy.EventArguments
55
{
6+
/// <summary>
7+
/// Class that wraps the multipart sent request arguments.
8+
/// </summary>
69
public class MultipartRequestPartSentEventArgs : EventArgs
710
{
811
public MultipartRequestPartSentEventArgs(string boundary, HeaderCollection headers)
@@ -11,8 +14,14 @@ public MultipartRequestPartSentEventArgs(string boundary, HeaderCollection heade
1114
Headers = headers;
1215
}
1316

17+
/// <summary>
18+
/// Boundary
19+
/// </summary>
1420
public string Boundary { get; }
1521

22+
/// <summary>
23+
/// The header collection.
24+
/// </summary>
1625
public HeaderCollection Headers { get; }
1726
}
1827
}

Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
namespace Titanium.Web.Proxy.EventArguments
1616
{
1717
/// <summary>
18-
/// Holds info related to a single proxy session (single request/response sequence)
19-
/// A proxy session is bounded to a single connection from client
18+
/// Holds info related to a single proxy session (single request/response sequence).
19+
/// A proxy session is bounded to a single connection from client.
2020
/// A proxy session ends when client terminates connection to proxy
21-
/// or when server terminates connection from proxy
21+
/// or when server terminates connection from proxy.
2222
/// </summary>
2323
public class SessionEventArgs : SessionEventArgsBase
2424
{
@@ -47,7 +47,7 @@ protected SessionEventArgs(int bufferSize, ProxyEndPoint endPoint,
4747
private bool hasMulipartEventSubscribers => MultipartRequestPartSent != null;
4848

4949
/// <summary>
50-
/// Should we send the request again
50+
/// Should we send the request again ?
5151
/// </summary>
5252
public bool ReRequest
5353
{
@@ -346,9 +346,10 @@ private async Task<long> ReadUntilBoundaryAsync(CustomBinaryReader reader, long
346346
}
347347

348348
/// <summary>
349-
/// Gets the request body as bytes
349+
/// Gets the request body as bytes.
350350
/// </summary>
351-
/// <returns></returns>
351+
/// <param name="cancellationToken"></param>
352+
/// <returns>The body as bytes.</returns>
352353
public async Task<byte[]> GetRequestBody(CancellationToken cancellationToken = default)
353354
{
354355
if (!WebSession.Request.IsBodyRead)
@@ -360,9 +361,10 @@ public async Task<byte[]> GetRequestBody(CancellationToken cancellationToken = d
360361
}
361362

362363
/// <summary>
363-
/// Gets the request body as string
364+
/// Gets the request body as string.
364365
/// </summary>
365-
/// <returns></returns>
366+
/// <param name="cancellationToken">Cancellation token for this async task is optional.</param>
367+
/// <returns>The body as string.</returns>
366368
public async Task<string> GetRequestBodyAsString(CancellationToken cancellationToken = default)
367369
{
368370
if (!WebSession.Request.IsBodyRead)
@@ -374,9 +376,9 @@ public async Task<string> GetRequestBodyAsString(CancellationToken cancellationT
374376
}
375377

376378
/// <summary>
377-
/// Sets the request body
379+
/// Sets the request body.
378380
/// </summary>
379-
/// <param name="body"></param>
381+
/// <param name="body">The request body bytes.</param>
380382
public void SetRequestBody(byte[] body)
381383
{
382384
var request = WebSession.Request;
@@ -389,9 +391,9 @@ public void SetRequestBody(byte[] body)
389391
}
390392

391393
/// <summary>
392-
/// Sets the body with the specified string
394+
/// Sets the body with the specified string.
393395
/// </summary>
394-
/// <param name="body"></param>
396+
/// <param name="body">The request body string to set.</param>
395397
public void SetRequestBodyString(string body)
396398
{
397399
if (WebSession.Request.Locked)
@@ -403,7 +405,7 @@ public void SetRequestBodyString(string body)
403405
}
404406

405407
/// <summary>
406-
/// Gets the response body as byte array
408+
/// Gets the response body as bytes.
407409
/// </summary>
408410
/// <returns></returns>
409411
public async Task<byte[]> GetResponseBody(CancellationToken cancellationToken = default)
@@ -417,9 +419,9 @@ public async Task<byte[]> GetResponseBody(CancellationToken cancellationToken =
417419
}
418420

419421
/// <summary>
420-
/// Gets the response body as string
422+
/// Gets the response body as string.
421423
/// </summary>
422-
/// <returns></returns>
424+
/// <returns>The string body.</returns>
423425
public async Task<string> GetResponseBodyAsString(CancellationToken cancellationToken = default)
424426
{
425427
if (!WebSession.Response.IsBodyRead)
@@ -431,7 +433,7 @@ public async Task<string> GetResponseBodyAsString(CancellationToken cancellation
431433
}
432434

433435
/// <summary>
434-
/// Set the response body bytes
436+
/// Set the response body bytes.
435437
/// </summary>
436438
/// <param name="body"></param>
437439
public void SetResponseBody(byte[] body)
@@ -446,7 +448,7 @@ public void SetResponseBody(byte[] body)
446448
}
447449

448450
/// <summary>
449-
/// Replace the response body with the specified string
451+
/// Replace the response body with the specified string.
450452
/// </summary>
451453
/// <param name="body"></param>
452454
public void SetResponseBodyString(string body)
@@ -462,9 +464,8 @@ public void SetResponseBodyString(string body)
462464
}
463465

464466
/// <summary>
465-
/// Before request is made to server
466-
/// Respond with the specified HTML string to client
467-
/// and ignore the request
467+
/// Before request is made to server respond with the specified HTML string to client
468+
/// and ignore the request.
468469
/// </summary>
469470
/// <param name="html"></param>
470471
/// <param name="headers"></param>
@@ -483,9 +484,8 @@ public void Ok(string html, Dictionary<string, HttpHeader> headers = null)
483484
}
484485

485486
/// <summary>
486-
/// Before request is made to server
487-
/// Respond with the specified byte[] to client
488-
/// and ignore the request
487+
/// Before request is made to server respond with the specified byte[] to client
488+
/// and ignore the request.
489489
/// </summary>
490490
/// <param name="result"></param>
491491
/// <param name="headers"></param>
@@ -501,9 +501,8 @@ public void Ok(byte[] result, Dictionary<string, HttpHeader> headers = null)
501501

502502
/// <summary>
503503
/// Before request is made to server 
504-
/// Respond with the specified HTML string to client
505-
/// and the specified status
506-
/// and ignore the request 
504+
/// respond with the specified HTML string and the specified status to client.
505+
/// And then ignore the request. 
507506
/// </summary>
508507
/// <param name="html"></param>
509508
/// <param name="status"></param>
@@ -520,10 +519,8 @@ public void GenericResponse(string html, HttpStatusCode status, Dictionary<strin
520519
}
521520

522521
/// <summary>
523-
/// Before request is made to server
524-
/// Respond with the specified byte[] to client
525-
/// and the specified status
526-
/// and ignore the request
522+
/// Before request is made to server respond with the specified byte[],
523+
/// the specified status to client. And then ignore the request.
527524
/// </summary>
528525
/// <param name="result"></param>
529526
/// <param name="status"></param>
@@ -540,7 +537,7 @@ public void GenericResponse(byte[] result, HttpStatusCode status, Dictionary<str
540537
}
541538

542539
/// <summary>
543-
/// Redirect to URL.
540+
/// Redirect to provided URL.
544541
/// </summary>
545542
/// <param name="url"></param>
546543
/// <returns></returns>

Titanium.Web.Proxy/ExceptionHandler.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22

33
namespace Titanium.Web.Proxy
44
{
5+
/// <summary>
6+
/// A delegate to catch exceptions occuring in proxy.
7+
/// </summary>
8+
/// <param name="exception">The exception occurred in proxy.</param>
59
public delegate void ExceptionHandler(Exception exception);
610
}

0 commit comments

Comments
 (0)