HTTP2::Request
One HTTP request. The client derives HTTP/2 pseudo-fields from the method, target, and its origin; callers provide only regular fields.
Constructors
Creates a request. target is an origin-form path, an absolute URI for
the same client origin, * for OPTIONS, or authority form for CONNECT.
An IO body (not a String/Bytes body, whose length is always
exactly known) combined with an explicit content-length header in
headers MUST report EOF (a #read returning 0) at exactly that
declared length. The client verifies this by reading one byte past
the declared length before finishing the request, to reject a body
that silently runs longer than declared (InvalidRequestError)
instead of truncating it. That verification read is a real, blocking
IO#read call with no timeout of its own — a source that has
exactly content-length bytes available and then blocks instead of
returning 0 (e.g. a live socket or pipe with no more data queued
yet, rather than actually closed) blocks the upload indefinitely
instead of completing the request. IO::Memory, File, IO::Sized,
HTTP::FixedLengthContent, and similar EOF reliably at a declared
length and are unaffected; an IO body with no explicit
content-length header is read to EOF with no probe and is also
unaffected (CONNECT tunnel bodies always take this path, since
CONNECT forbids content-length).
Instance methods
An IO view of the body, kept for API compatibility with callers
that want to read it as a stream. For an owned String/Bytes body
this wraps @owned_body in an IO::Memory only on first access,
then memoizes it -- Client's upload fast path never calls this;
it reads @owned_body directly, so a request whose body is never
inspected via this getter never allocates the wrapper at all.
Unsynchronized, so two concurrent first accesses (-Dpreview_mt)
could each build a wrapper and the later assignment wins -- benign,
since both wrap the same bytes and only one is ever kept.
The backing bytes of a String/Bytes body, exposed so Client's
upload fast path can hand them straight to Stream#send_data
without ever wrapping them in an IO -- not part of the public API.
:nodoc:
Whether the client can reproduce this body for a proven-unprocessed retry. String and Bytes bodies are owned; caller-supplied IO is not.