Skip to content

Phase 1, Task 4: Rewrite HtmlRewriterAdapter for incremental streaming #571

@aram356

Description

@aram356

Parent: #563
Phase: #566

Summary

HtmlRewriterAdapter accumulates the entire HTML document before processing, despite lol_html supporting incremental write() calls. Rewrite to emit output on every process_chunk() call.

Changes

  • Create rewriter eagerly in constructor with Rc<RefCell<Vec<u8>>> shared output sink via lol_html::OutputSink trait
  • process_chunk() drains buffer after each rewriter.write() — emits output per chunk
  • Adapter becomes single-use: reset() is a no-op (Settings consumed by constructor)
  • Update existing tests that assert empty intermediate output
  • Add test proving per-chunk output emission

File: crates/trusted-server-core/src/streaming_processor.rs:396-472

Note: HtmlWithPostProcessing wraps this adapter and passes through intermediate output for !is_last chunks. No changes needed to html_processor.rs.

Plan

See docs/superpowers/plans/2026-03-25-streaming-response.md — Task 4

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