Skip to content

Add RawBody to RequestInfo for non-text payload validation#157

Merged
dennisdoomen merged 1 commit into
mainfrom
issue-156-raw-body-requestinfo
Jul 5, 2026
Merged

Add RawBody to RequestInfo for non-text payload validation#157
dennisdoomen merged 1 commit into
mainfrom
issue-156-raw-body-requestinfo

Conversation

@dennisdoomen

Copy link
Copy Markdown
Owner

Summary

Add raw request body bytes to RequestInfo and CapturedRequest so non-text payloads can be validated.

Changes

  • add RequestInfo.RawBody and a constructor overload accepting raw bytes
  • derive textual Body from prefetched bytes for textual media types to avoid dual payload sources
  • prefetch request content as bytes in HttpMock
  • expose CapturedRequest.RawBody
  • keep unexpected-request diagnostics consistent for binary payloads
  • add/adjust specs for textual, binary, and PrefetchBody = false scenarios
  • update API approval baselines for
    et8.0 and
    et472

Closes #156

Comment thread Mockly.Specs/HttpMockSpecs.cs Fixed
Comment thread Mockly.Specs/HttpMockSpecs.cs Fixed
Comment thread Mockly/CapturedRequest.cs Fixed
Comment thread Mockly/RequestInfo.cs Fixed
@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown

Test Results

  3 files  ±0    3 suites  ±0   10s ⏱️ -1s
196 tests +3  196 ✅ +3  0 💤 ±0  0 ❌ ±0 
389 runs  +6  389 ✅ +6  0 💤 ±0  0 ❌ ±0 

Results for commit dcd88cd. ± Comparison against base commit 2c610f2.

This pull request removes 1 and adds 4 tests. Note that renamed tests count towards both.
Mockly.Specs.HttpMockSpecs+SequencedResponses ‑ The_Responder_property_still_exposes_the_first_response
Mockly.Specs.HttpMockSpecs+SequencedResponses ‑ The_responder_property_still_exposes_the_first_response
Mockly.Specs.HttpMockSpecs+WhenCollectingRequests ‑ Exposes_the_raw_bytes_of_a_binary_captured_request
Mockly.Specs.HttpMockSpecs+WhenCollectingRequests ‑ Exposes_the_textual_body_of_a_captured_request
Mockly.Specs.HttpMockSpecs+WhenUsingAsyncResponders ‑ An_async_responder_receives_binary_request_body_as_raw_bytes

♻️ This comment has been updated with latest results.

@coveralls

coveralls commented Jun 29, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 28732059354

Coverage increased (+0.1%) to 84.789%

Details

  • Coverage increased (+0.1%) from the base build.
  • Patch coverage: 3 uncovered changes across 1 file (34 of 37 lines covered, 91.89%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
Mockly/RequestInfo.cs 27 24 88.89%
Total (5 files) 37 34 91.89%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 1501
Covered Lines: 1341
Line Coverage: 89.34%
Relevant Branches: 491
Covered Branches: 348
Branch Coverage: 70.88%
Branches in Coverage %: Yes
Coverage Strength: 338.4 hits per line

💛 - Coveralls

@dennisdoomen dennisdoomen force-pushed the issue-156-raw-body-requestinfo branch from 9335333 to 2752c1b Compare July 5, 2026 06:18
Comment thread Mockly.Specs/HttpMockSpecs.cs Fixed
Comment thread Mockly.Specs/HttpMockSpecs.cs Fixed
@dennisdoomen dennisdoomen force-pushed the issue-156-raw-body-requestinfo branch from 2752c1b to 6a55961 Compare July 5, 2026 06:31
Capture request bodies once as bytes during prefetching and expose them through RequestInfo and CapturedRequest.

Keep Body compatibility by deriving textual content from prefetched bytes for textual media types, and preserve binary diagnostics behavior.

Add spec coverage for raw-body capture and update API approval snapshots.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dennisdoomen dennisdoomen force-pushed the issue-156-raw-body-requestinfo branch from 6a55961 to dcd88cd Compare July 5, 2026 06:32
@dennisdoomen dennisdoomen merged commit ef8beab into main Jul 5, 2026
10 checks passed
@dennisdoomen dennisdoomen deleted the issue-156-raw-body-requestinfo branch July 5, 2026 06:39
@dennisdoomen dennisdoomen added this to the 1.9.0 milestone Jul 5, 2026
@dennisdoomen dennisdoomen added the enhancement New feature or request label Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API Proposal]: Add the RawBody to the Requestinfo to validate non-text bodies

3 participants