Skip to content

Commit

Permalink
Update variable context definition and enhance doc comments in Exchan…
Browse files Browse the repository at this point in the history
…geContext

The code clarifies the definition of VariableContext to depict its unique nature per proxy instance instead of being a singleton. Also, extensive documentation comments have been added throughout the ExchangeContext.cs class, enriching descriptions of properties and functions. Additionally, a minor spelling mistake in IStreamSubstitution.cs is rectified for better readability.
  • Loading branch information
haga-rak committed Dec 8, 2023
1 parent a4cb3e3 commit f9d3732
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 9 deletions.
70 changes: 63 additions & 7 deletions src/Fluxzy.Core/Core/ExchangeContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

namespace Fluxzy.Core
{
/// <summary>
/// Holds the mutable state of the ongoing exchange
/// </summary>
public class ExchangeContext
{
public ExchangeContext(
Expand All @@ -26,7 +29,16 @@ public ExchangeContext(
FluxzySetting = fluxzySetting;
}

/// <summary>
/// Remote authority, this value is used to build the host header on H11/request and
/// :authority pseudo header on H2/request
/// </summary>
public IAuthority Authority { get; set; }

/// <summary>
/// If the ongoing connection to Authority should use TLS
/// </summary>
public bool Secure { get; set; }

/// <summary>
/// Host IP that shall be used instead of a classic DNS resolution
Expand Down Expand Up @@ -82,32 +94,76 @@ public ExchangeContext(
/// </summary>
public bool SkipRemoteCertificateValidation { get; set; } = false;

/// <summary>
/// Gets or sets the list of header alterations for the request.
/// </summary>
/// <value>
/// The list of <see cref="HeaderAlteration"/> objects representing the header alterations for the request.
/// </value>
public List<HeaderAlteration> RequestHeaderAlterations { get; } = new();

/// <summary>
/// Gets or sets the list of response header alterations.
/// </summary>
/// <value>
/// The list of response header alterations.
/// </value>
public List<HeaderAlteration> ResponseHeaderAlterations { get; } = new();

/// <summary>
/// Holds information about a breakpoint context.
/// </summary>
public BreakPointContext? BreakPointContext { get; set; }

/// <summary>
/// Gets the variable context associated with the current object.
/// </summary>
/// <remarks>
/// The VariableContext property provides access to the variable context, which represents the scope and lifetime of variables used within the current object. The variable context stores
/// variables as key-value pairs and allows access to their values.
/// </remarks>
/// <returns>
/// The variable context associated with the current object.
/// </returns>
public VariableContext VariableContext { get; }

public VariableBuildingContext? VariableBuildingContext { get; set; } = null;
/// <summary>
/// Information about the ongoing exchange and connection
/// </summary>
public VariableBuildingContext? VariableBuildingContext { get; internal set; } = null;

/// <summary>
/// The proxy setting
/// </summary>
public FluxzySetting? FluxzySetting { get; }

/// <summary>
/// Gets or sets the down stream local IP address of the struct.
/// </summary>
/// <value>
/// The down stream local IP address.
/// </value>
public IPAddress DownStreamLocalAddressStruct { get; set; } = null!;

public int ProxyListenPort { get; set; }

public bool Secure { get; set; }
/// <summary>
/// Information about the proxy port that has been used to retrieve the ongoing exchange
/// </summary>
public int ProxyListenPort { get; internal set; }

public NetworkStream? UnderlyingBcStream { get; set; }
internal NetworkStream? UnderlyingBcStream { get; set; }

public DisposeEventNotifierStream? EventNotifierStream { get; set; }
internal DisposeEventNotifierStream? EventNotifierStream { get; set; }

public Dictionary<Filter, bool> FilterEvaluationResult { get; } = new();
internal Dictionary<Filter, bool> FilterEvaluationResult { get; } = new();

/// <summary>
/// Gets or sets the request body substitution.
/// </summary>
public IStreamSubstitution? RequestBodySubstitution { get; set; }

/// <summary>
/// Gets or sets the substitution for the response body.
/// </summary>
public IStreamSubstitution? ResponseBodySubstitution { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/Fluxzy.Core/Core/IStreamSubstitution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public interface IStreamSubstitution
{
/// <summary>
/// This class is used to low level-mock request and response body.
/// Even if this class is async for fast mocking purpose, calling async in the implementation will lead to unecessary overhead.
/// Even if this class is async for fast mocking purpose, calling async in the implementation will lead to unnecessary overhead.
/// Additionally, you must drain (read to EOF) the provided stream in order to not hang the remote connection when
/// the original stream is coming from a remote connection.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Fluxzy.Core/Rules/VariableContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Fluxzy.Rules
{
/// <summary>
/// Retrieving variables and updating variables.
/// This object is a singleton according to the proxy instance .
/// This object is unique per proxy instance
/// </summary>
public class VariableContext
{
Expand Down

0 comments on commit f9d3732

Please sign in to comment.