Repository navigation
1.2.0: a socket transport under send(), streaming request bodies - #8
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Client
send()now runs aSocketTransport: 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 itsContent-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 aResponseBodyresource decoded as the server framed it, chunked, counted byContent-Length, or until the server closes, and the socket is closed when the body ends.HEAD,204and304have 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:
ResponseBodyTestdecodes the three framings overphp://memory;TransportTestboots 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 existingClientTestagainstphp -S, 200,000 rows included, passes on the new transport.Server
PhpServerreadsphp://inputin 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
ResponseBodyimplementsCloseableandPhpServerreads throughreadHandle; both are one-line follow-ups kept out of this PR so it builds on streams 1.4.