Skip to content

client: return one-frame response bodies without copying - #265

Open
allada wants to merge 1 commit into
connectrpc:mainfrom
allada:collect-body-zero-copy
Open

client: return one-frame response bodies without copying#265
allada wants to merge 1 commit into
connectrpc:mainfrom
allada:collect-body-zero-copy

Conversation

@allada

@allada allada commented Aug 2, 2026

Copy link
Copy Markdown

collect_body_bounded copied every frame into a BytesMut, including the common case of a body that arrives whole in one frame. Hold the first frame by reference count and return it directly when no second frame follows; promote to a buffer only when one does.

Using http_body_util::Limited here instead would need B::Error to be std::error::Error rather than Display, which propagates to ServerStream and BidiStream and the transport trait's body. Not worth a public API break for this.

collect_body_bounded copied every frame into a BytesMut, including the
common case of a body that arrives whole in one frame. Hold the first
frame by reference count and return it directly when no second frame
follows; promote to a buffer only when one does.

Using http_body_util::Limited here instead would need B::Error to be
std::error::Error rather than Display, which propagates to ServerStream
and BidiStream and the transport trait's body. Not worth a public API
break for this.

Signed-off-by: Blaise Bruer <github.blaise@allada.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant