Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.
This repository was archived by the owner on Nov 25, 2025. It is now read-only.

[v0.3]: Changes to consume-body #176

@alexcrichton

Description

@alexcrichton

There was some discussion today about consume-body, possible changes, and consequences of various design decisions. I wanted to write down what I recall are the results of the discussion to make sure they don't get lost, but @rvolosatovs, @lukewagner, @lann, or @dicej correct me if I'm wrong.

The discussion started with the problem of: the consume-body semantics of today are surprisingly heavyweight to implement, notably the "after you close the handles handed out you can call consume-body again" part. We concluded that this should be removed to make consume-body callable at most one time.

The discussion then veered into how there's also problems around implementing the future returned from request/response constructors right now. For example it's not clear how to resolve those futures when the request/response is created in a guest and then passed to another guest. What sort of needs to happen is that the writer is owned by the request or response object (e.g. on the host) and somehow that needs to be written to, but with the current API it's not clear when.

To resolve this we ended up concluding that consume-body should take a future<result<_, error-code>> as an argument. This is a guest's indication of "I'm taking the body, and the result of my processing the body will be this future". The future is then "fused" with the write end already present in the response or request, completing the chain of how to resolve it.

There was a lot of other discussion and alternatives I'm not capturing here for now, too. There's also some various edge cases we probably still need to worry about here (e.g. should the future argument be optional for performance today?) which may still need hammering out.

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