Skip to content

Phase 4, Task 16: Stream binary pass-through responses via io::copy #592

@aram356

Description

@aram356

Parent: #563

Summary

Non-processable responses (images, fonts, video, `application/octet-stream`) currently pass through `handle_publisher_request` unchanged via the `Buffered` path. This buffers the entire response body in memory before sending to the client — wasteful for large binaries that need no processing.

Changes

  • Add `PublisherResponse::PassThrough { response, body }` variant — signals the adapter to stream the body directly via `io::copy` into `StreamingBody` with no pipeline
  • Return `PassThrough` when `!should_process` and backend returned 2xx
  • Update `main.rs` adapter to handle the new variant with `stream_to_client()` + `io::copy(body, &mut streaming_body)`
  • Keep `Buffered` for non-2xx responses (error pages) and `request_host.is_empty()`

Files: `publisher.rs`, `main.rs`

Expected impact

Eliminates peak memory for large binary responses (images can be 1-10 MB). Improves DOM Complete for image-heavy pages since the browser receives image bytes earlier.

Plan

See `docs/superpowers/specs/2026-03-25-streaming-response-design.md`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions