Skip to content

feat(http): add RespondBytes for raw binary response payloads - #133

Merged
ncipollina merged 5 commits into
mainfrom
feat/http-respond-bytes
Sep 4, 2026
Merged

feat(http): add RespondBytes for raw binary response payloads#133
ncipollina merged 5 commits into
mainfrom
feat/http-respond-bytes

Conversation

@ncipollina

Copy link
Copy Markdown
Contributor

Summary

Adds HttpResponseRegistrationBuilder.RespondBytes(byte[], mediaType) to Compono.Http, closing a gap between RespondText and RespondJson: no way to serve a raw binary payload. Surfaced by dogfood evidence in alexa-vox-craft, where a test needing to serve a fetched certificate's DER bytes had to round-trip them through Encoding.Latin1 text as a workaround.

Changes

  • src/Compono.Http/HttpResponseRegistrationBuilder.cs - new RespondBytes(byte[] content, string mediaType = "application/octet-stream"), following RespondJson's serialize-once-to-bytes model (content captured once, a fresh ByteArrayContent + MediaTypeHeaderValue per matched invocation).
  • docs/adr/0051-compono-http-handler-based-testing-package.md - recorded as Amendment 2 (purely additive, source-compatible extension, not a reversal of the original decision).
  • test/Compono.Http.Tests/TestHttpHandlerTests.cs - two new tests: byte round-trip with default content type, and custom media type.
  • docs/reference/api/Compono.Http/ - regenerated via .github/scripts/generate-api-reference.sh.

Validation

  • dotnet test test/Compono.Http.Tests/Compono.Http.Tests.csproj -f net10.0 - 31/31 passed
  • Also ran the two new tests standalone on net9.0
  • API reference regenerated from a Release/net10.0 build; diff scoped to the new method's page + index entry

Closes the gap between RespondText and RespondJson - a consumer needing
to serve raw bytes (e.g. a fetched certificate's DER bytes) previously
had to round-trip through a Latin1-encoded string, an awkward workaround
surfaced by dogfood evidence in alexa-vox-craft. Follows RespondJson's
serialize-once-to-bytes model; recorded as ADR-0051 Amendment 2.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GMQEjFrUVGYkctE3ECfRuA
@github-actionsgithub-actionsBot added the type: feat New feature label Sep 4, 2026

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:f035438b42

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadsrc/Compono.Http/HttpResponseRegistrationBuilder.cs Outdated
Comment threadsrc/Compono.Http/HttpResponseRegistrationBuilder.cs
j-d-ha
j-d-ha previously approved these changes Sep 4, 2026

@j-d-haj-d-ha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

…ge guide
Address Codex review feedback on PR #133: RespondBytes retained the
caller's byte[] by reference instead of copying it, so a post-registration
mutation or buffer reuse would silently change an already-registered
response - breaking the serialize-once snapshot semantics RespondJson
already provides and this method's own doc claimed to match. Also add
RespondBytes to docs/packages/compono-http.md's Response APIs list, which
was updated everywhere except the consumer-facing package guide.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GMQEjFrUVGYkctE3ECfRuA
@ncipollina

Copy link
Copy Markdown
ContributorAuthor

@codex review commit 4bc5838 — addresses both prior findings: RespondBytes now defensively copies content at registration (HttpResponseRegistrationBuilder.cs), and RespondBytes was added to docs/packages/compono-http.md's Response APIs list.

…edback
The task file's Phase 3 covered replying to and resolving feedback but
never mentioned requesting a fresh bot review scoped to the fix commit
once real code changes are pushed - an established pattern this session
used, now made explicit so it isn't re-derived ad hoc next time.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GMQEjFrUVGYkctE3ECfRuA

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:4bc5838f5a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadsrc/Compono.Http/HttpResponseRegistrationBuilder.cs
Comment threadsrc/Compono.Http/HttpResponseRegistrationBuilder.cs
ncipollinaand others added 2 commits September 4, 2026 15:11
…erence
The published compono skill's http.md enumerated every Respond* finalizer
for consumers writing Compono.Http tests, but was written before
RespondBytes existed (PR #133). Add it alongside the others so skill
guidance doesn't quietly fall behind the package's actual API surface.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GMQEjFrUVGYkctE3ECfRuA
Address Codex review feedback on PR #133: PLAN-0051's Response APIs
(Task 4) and Behavioral tests (Task 9) checklists still only enumerated
the pre-Amendment-2 Respond* set, so the plan no longer accurately
reflected Compono.Http's completed public behavior and test coverage.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GMQEjFrUVGYkctE3ECfRuA
@ncipollina
ncipollina merged commit 87284e4 into mainSep 4, 2026
11 checks passed
@ncipollina
ncipollina deleted the feat/http-respond-bytes branch September 4, 2026 19:19
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: featNew feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@ncipollina@j-d-ha