Record request headers and bodies and show them per catch
Build and deploy / build (push) Successful in 1m29s
Release / image (push) Successful in 1m53s
Build and deploy / deploy (push) Successful in 30s
Release / release (push) Successful in 6s

Headers and the first 8 KB of the body are stored unmasked for 30 days,
read alongside the response so the trap answers as before. MCP get_request
and the expanded catch row show them. Changelog prepared for 0.10.0.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
TomandClaude Sonnet 5.5 committed 2026-11-26 21:47:28 +01:00
1 parent a46727bab3
commit b559f83550
35 files changed
+1012 -18

No files matched your search

@@ -0,0 +1,8 @@
using Flypaper.Core.Models;
namespace Flypaper.Core.Abstractions;
public interface IRequestCapture
{
ValueTask<RequestDetails?> CompleteAsync();
}
+2
View File
@@ -14,5 +14,7 @@ public sealed class FlypaperOptions
public TimeSpan RepeatHoldDuration { get; set; } = TimeSpan.FromHours(24);
public bool CaptureRequests { get; set; } = true;
public bool IgnorePrivateNetworks { get; set; } = true;
}
@@ -0,0 +1,3 @@
namespace Flypaper.Core.Models;
public sealed record RequestDetails(string Headers, string? Body, long? ContentLength, bool Truncated);
+3 -1
View File
@@ -1,3 +1,5 @@
using Flypaper.Core.Abstractions;
namespace Flypaper.Core.Models;
public sealed record TrapContext(TrapSession Session, string? Target = null, string? ClientInfo = null, string? Path = null, bool IsNewIp = false);
public sealed record TrapContext(TrapSession Session, string? Target = null, string? ClientInfo = null, string? Path = null, bool IsNewIp = false, IRequestCapture? Capture = null);
+2 -1
View File
@@ -12,7 +12,8 @@ public sealed record TrapEvent(
long BytesSent,
TrapOutcome Outcome,
string? Target = null,
string? ClientInfo = null)
string? ClientInfo = null,
RequestDetails? Request = null)
{
public TimeSpan Duration => EndedAt - StartedAt;
}
+8 -5
View File
@@ -27,7 +27,7 @@ public sealed partial class TrapRunner(
if (strategy is null || !governor.TryAcquire(session, out var lease))
{
Publish(context, strategy?.Name ?? "none", 0, TrapOutcome.Rejected);
Publish(context, strategy?.Name ?? "none", 0, TrapOutcome.Rejected, timeProvider.GetUtcNow(), null);
return TrapOutcome.Rejected;
}
@@ -71,11 +71,13 @@ public sealed partial class TrapRunner(
outcome = TrapOutcome.ClientAborted;
}
Publish(context, description, channel?.BytesSent ?? 0, outcome);
var endedAt = timeProvider.GetUtcNow();
var request = context.Capture is null ? null : await context.Capture.CompleteAsync();
Publish(context, description, channel?.BytesSent ?? 0, outcome, endedAt, request);
return outcome;
}
private void Publish(TrapContext context, string strategy, long bytesSent, TrapOutcome outcome)
private void Publish(TrapContext context, string strategy, long bytesSent, TrapOutcome outcome, DateTimeOffset endedAt, RequestDetails? request)
{
var session = context.Session;
var trapEvent = new TrapEvent(
@@ -84,11 +86,12 @@ public sealed partial class TrapRunner(
session.RemoteIp,
strategy,
session.StartedAt,
timeProvider.GetUtcNow(),
endedAt,
bytesSent,
outcome,
context.Target,
context.ClientInfo);
context.ClientInfo,
request);
var store = !(options.CurrentValue.IgnorePrivateNetworks && PrivateNetworks.Contains(trapEvent.RemoteIp));
var storageNote = store ? "" : " (not stored)";