Skip to content

Support reading Fetch response bodies as streams #919

@johanbrandhorst

Description

@johanbrandhorst

Is your feature request related to a problem? Please describe.
When making web requests to servers, the returned data is sometimes streamed so that early results can be used immediately, instead of waiting for the whole request to finish. It also allows the use of never-ending streams which continuously stream data (as an alternative to websockets).

Describe the solution you'd like
The yew response body should contain a way to stream the data from the Fetch response body type.

The type returned from fetch: https://developer.mozilla.org/en-US/docs/Web/API/Response. The type of Response.body: https://developer.mozilla.org/en-US/docs/Web/API/Body/body.

More information
This is where we discard the stream today:

(std_web):

var promise = (@{binary}) ? response.arrayBuffer() : response.text();

(web_sys):

let data_promise = if self.binary {
response.array_buffer()
} else {
response.text()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions