Skip to content

No way to ask http1::Decoder whether it is mid-message #80

Description

@proggeramlug

Problem

http1::Decoder gives no predicate for "am I currently inside a response/request body." The only way to ask is eof(), which answers by returning an error or not — i.e. the only way to find out is to tell the decoder the connection closed and see what it says.

Why it matters

Perry's P11 lane (perry-http-client, the perry CLI's blocking HTTP/1 client) needs this on every connection: when a read() returns zero, the caller has to decide whether that's a legal end of body (Connection: close, body ends at EOF) or a truncated response cut off mid-message. Today the only mechanism is calling eof() and inspecting whether it errors, so the decision and the query are fused into one call — there is no way to check first and choose different handling (retry, hard-fail, log a specific diagnosis) before committing to the EOF path.

What would fix it

A Decoder::wants_step()-style predicate (the same shape turnloop#50 proposes for the zero-consume Event::End case), or an explicit Decoder::in_body() / Decoder::is_mid_message() query that answers from current state without needing to feed EOF first.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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