Skip to content

Two stage in response #2

@xbwwj

Description

@xbwwj

Decoding response body also takes time. This fact is reflected in API design of Response.text() in web fetch and reqwest.

In traditional game engine like UE FHttpModule, OnProcessRequestComplete is triggered only when full response (including body) is processed. Bevy, as a engine targeting high performance, should be able to achieve this in its API. The full processing can still be the default, we can provide an extra component to instruct bevy to do the correct and intended body processing (e.g. text/json::<T>).

The response event can accordingly be split into two:

  • RequestReceived: The response header received, which is await fetch() in JS and request.send() in reqwest.
  • RequestComplete: The response is fully processed, await response.text() and response.text().await

Questions need further pondering:

  1. The ambiguity in name: RequestComplete follows the UE name, but the meaning of RequestReceived is not apparent.
  2. Should text and json be separate component?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions