Skip to content

1.2.0: a socket transport under send(), streaming request bodies - #8

Merged
MarcelloDuarte merged 3 commits into
mainfrom
developing-1.2.0
Oct 15, 2026
Merged

MarcelloDuarte merged 3 commits into
mainfrom
developing-1.2.0

Conversation

@MarcelloDuarte

Copy link
Copy Markdown
Contributor

Client

send() now runs a SocketTransport: one HTTP/1.1 connection per request, plain or TLS, Connection: close. The request body is framed by what the stream knows: a pure body (built from a string) goes out with its Content-Length, a resource-backed body goes out with chunked transfer encoding, one chunk written as it is pulled, so an upload of any size streams through. The response head is read first; the body is a ResponseBody resource decoded as the server framed it, chunked, counted by Content-Length, or until the server closes, and the socket is closed when the body ends. HEAD, 204 and 304 have no body.

Behaviour change: redirects are no longer followed (the previous transport, PHP's http:// wrapper, followed them); a 3xx comes back as it is.

Tests: ResponseBodyTest decodes the three framings over php://memory; TransportTest boots a raw socket fixture server that reports the request it received and answers with each framing, and checks a 300 KB resource body goes out chunked in 300 pulls with the right hash. The existing ClientTest against php -S, 200,000 rows included, passes on the new transport.

Server

PhpServer reads php://input in 64 KB chunks instead of 256 bytes.

Docs

The four pages the index linked to as one-line stubs are written: Type Signatures, Route Definition, Path Parameters, Types. The client page has a transport section.

After streams 1.5.0 lands on Packagist

ResponseBody implements Closeable and PhpServer reads through readHandle; both are one-line follow-ups kept out of this PR so it builds on streams 1.4.

@MarcelloDuarte
MarcelloDuarte merged commit 9921183 into main Oct 15, 2026
24 checks passed
@MarcelloDuarte
MarcelloDuarte deleted the developing-1.2.0 branch October 15, 2026 11:04
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