Streaming body parser: Form Urlencoded #202
Streaming body parser: Form Urlencoded #202WyriHaximus wants to merge 4 commits intoreactphp:masterfrom
Conversation
|
Next PR will add streaming body parser documentation to |
| public function __construct(RequestInterface $request) | ||
| { | ||
| $this->request = $request; | ||
| $this->body = $this->request->getBody(); |
There was a problem hiding this comment.
Maybe check here if $this->body is an instance of HttpBodyStream?
There was a problem hiding this comment.
WDYT? Since the class isn't internal, it isn't guaranteed that $this->body is an instance of HttpBodyStream.
There was a problem hiding this comment.
I'm thinking a check on if body is a ReadableStreamInterface and else throw an exception.
| * | ||
| * @internal | ||
| */ | ||
| public $body; |
There was a problem hiding this comment.
Nope because of PHP 5.3 here https://github.com/WyriHaximus/http/blob/97ade3db7e4b1fe079cff9a6643e61975e179b59/src/StreamingBodyParser/FormUrlencodedParser.php#L39-L43 or I could make a public onEnd method, mark it private and make everything that shouldn't be public private.
There was a problem hiding this comment.
I'll look into refactoring it a bit anyway 👍
| * | ||
| * @internal | ||
| */ | ||
| public $buffer = ''; |
| /** | ||
| * @internal | ||
| */ | ||
| public function parse($buffer) |
| foreach (explode('&', $buffer) as $chunk) { | ||
| $this->emit( | ||
| 'post', | ||
| explode('=', rawurldecode($chunk)) |
There was a problem hiding this comment.
Not sure, but maybe ensure here that there will be always an array with to entries (key and value) emitted. so that key1&key2 emits array('key1', null) and array('key2', null)`?
|
@WyriHaximus superseded by #222? |
Related to #200 this adds the form urlencoded parser.