Skip to content

Streaming seems ineffective with process_response? #44

@TomStrepsil

Description

@TomStrepsil

Firstly, thanks for open sourcing this project, and great news on the Akamai-parity with the latest update.

I'm having some difficulty achieving streaming with a local Viceroy harness.

The docs suggest (under "Streaming Processing (recommended)")

// Stream the ESI response directly to the client
     processor.process_response(

Yet the process_response function appears to buffer everything:

pub fn process_response(
    mut self,
    src_stream: &mut Response,
    client_response_metadata: Option<Response>,
    dispatch_fragment_request: Option<&FragmentRequestDispatcher>,
    process_fragment_response: Option<&FragmentResponseProcessor>,
) -> Result<()> {
    let mut output = Vec::new();          // ← buffers into Vec
    self.process_stream(
        src_stream.take_body(),
        &mut output,                      // ← writes to Vec, not client
        dispatch_fragment_request,
        process_fragment_response,
    )?;
    // ... apply cache headers, $add_header, $set_response_code, $set_redirect ...
    resp.set_body(body_bytes.as_ref());
    resp.send_to_client();                // ← sends buffered body at the end
    Ok(())
}

...presumably to support the potential for response manipulation functions (as mentioned in the docs)?

Is there a way to get process_response to stream output?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions