Skip to content

async_get convenience wrapper, support custom methods - #17

Open
pgit wants to merge 2 commits into
masterfrom
headers
Open

pgit wants to merge 2 commits into
masterfrom
headers

Conversation

@pgit

@pgit pgit commented Sep 17, 2026

Copy link
Copy Markdown
Owner

No description provided.

pgit and others added 2 commits September 17, 2026 21:31
async_get() submits the request, ends its empty body, waits for the response and
reads all of it, handing back a plain Beast message -- status, header fields and
the body as a std::string, aliased as client::Message. What a simple GET spread
over four steps is one asynchronous operation now, completion tokens and
cancellation included.

Sending an actual GET means the method can no longer be hardcoded: all three
backends built their request with ":method: POST", so Session::Impl::async_submit()
takes the method as a parameter. The public async_submit() still passes "POST",
so nothing else changes on the wire.

The request goes out with "Content-Length: 0" unless the caller frames a body
itself. That keeps HTTP/1.1 from making a bodiless request chunked, and with it
from counting the request as incomplete -- and the session as busy -- until the
body is ended.

The message that comes with an error is empty and says status::unknown, rather
than the 200 a default-constructed Beast response would claim.

test_get.cpp covers status, fields, body, request headers, an empty body, a 1 MiB
one, two requests in a row and cancellation, for all three protocols, plus the
request line as a raw HTTP/1.1 peer sees it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The header, file handler and client testcases that send no request body and read
the response to its end say so in one line now. client::Message is a Beast fields,
so expect_contains() and values_of() take it unchanged.

FileHandler::get() was async_get() spelled out, and hands back the message itself
instead of a (status, body) tuple. HeaderLimits::request() loses its two error
checks along with the operations they belonged to.

These requests go out as GET with "Content-Length: 0" now, instead of as a chunked
POST -- which is what the testcases describe anyway.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.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