Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,21 @@ public void MaxEntries_negative_throws_InvalidOperationException()

Assert.Contains("MaxEntries", exception.Message);
}

[Fact]
public void MaxBodyCaptureSizeKb_negative_throws_ArgumentOutOfRangeException()
{
var options = new DebugProbeOptions();

Assert.Throws<ArgumentOutOfRangeException>(() => options.MaxBodyCaptureSizeKb = -1);
}

[Fact]
public void MaxBodyCaptureSizeKb_zero_is_valid()
{
var options = new DebugProbeOptions();
options.MaxBodyCaptureSizeKb = 0;

Assert.Equal(0, options.MaxBodyCaptureSizeKb);
}
}
15 changes: 13 additions & 2 deletions DebugProbe.AspNetCore/Options/DebugProbeOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace DebugProbe.AspNetCore.Options;
namespace DebugProbe.AspNetCore.Options;

/// <summary>
/// Configuration options for DebugProbe.
Expand All @@ -13,7 +13,18 @@ public class DebugProbeOptions
/// <summary>
/// Maximum captured request or response body size in kilobytes.
/// </summary>
public int MaxBodyCaptureSizeKb { get; set; } = 32;
private int _maxBodyCaptureSizeKb = 32;
public int MaxBodyCaptureSizeKb
{
get => _maxBodyCaptureSizeKb;
set
{
if (value < 0)
throw new ArgumentOutOfRangeException(nameof(MaxBodyCaptureSizeKb),
"MaxBodyCaptureSizeKb must be 0 or greater. Use 0 to disable body capture.");
_maxBodyCaptureSizeKb = value;
}
}

internal int MaxBodyCaptureSizeBytes => MaxBodyCaptureSizeKb * 1024;

Expand Down
Loading