Uh oh!
There was an error while loading. Please reload this page.
[WIP] Streaming parser bufferedsink - #73
Closed
WyriHaximus wants to merge 17 commits into
Closed
Conversation
8 tasks
jsor
reviewed
Oct 25, 2016
| self::extractPost($postFields, $key, $value); | ||
| }); | ||
| $parser->on('file', function ($name, File $file) use (&$files) { | ||
| StreamBufferedSink::createPromise($file->getStream())->then(function ($buffer) use ($name, $file, &$files) { |
jsor
commented
Oct 25, 2016
Member
What about splitting this into 3 distinct sinks: a body, post and files sink. The sinks could be composed with parts you need. The resolution array from the current implementation could be achieved with $promises = [
'body' => BodyBufferedSink::createPromise($parser),
'post' => PostBufferedSink::createPromise($parser),
'files' => FilesBufferedSink::createPromise($parser),
];
React\Promise\all($promises)->done($result) {
// $result contains 'body', 'post' and 'files `entries
}); |
WyriHaximus
commented
Oct 25, 2016
MemberAuthor
That is actually a great idea 👍 ! |
WyriHaximus
commented
Oct 26, 2016
MemberAuthor
@jsor updated the PR with the split up |
jsor
reviewed
Oct 26, 2016
| use React\Http\Request; | ||
| use React\Tests\Http\TestCase; | ||
| class PostPostBufferedSinkTest extends TestCase |
jsor
commented
Oct 26, 2016
Member
Maybe the class BufferedSink
{
/** * @param ParserInterface $parser * @return PromiseInterface */publicstaticfunctioncreatePromise(ParserInterface$parser)
{
$promises = [
'body' => BodyBufferedSink::createPromise($parser),
'post' => PostBufferedSink::createPromise($parser),
'files' => FilesBufferedSink::createPromise($parser),
];
returnPromise\all($promises);
}
} |
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 freeto 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.
Just like the bufferedsink from stream and #70 but this sink takes a streaming body parser and buffers any post field, body data, or uploaded file. Once the full request it in the promise will resolve.
Depends on #69 and #62