Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streaming body parser: Form Urlencoded #202

Conversation

WyriHaximus
Copy link
Member

Related to #200 this adds the form urlencoded parser.

@WyriHaximus
Copy link
Member Author

Next PR will add streaming body parser documentation to readme.md

public function __construct(RequestInterface $request)
{
$this->request = $request;
$this->body = $this->request->getBody();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe check here if $this->body is an instance of HttpBodyStream?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT? Since the class isn't internal, it isn't guaranteed that $this->body is an instance of HttpBodyStream.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking a check on if body is a ReadableStreamInterface and else throw an exception.

*
* @internal
*/
public $body;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're correct. My bad 🤗

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into refactoring it a bit anyway 👍

*
* @internal
*/
public $buffer = '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private?

/**
* @internal
*/
public function parse($buffer)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private?

foreach (explode('&', $buffer) as $chunk) {
$this->emit(
'post',
explode('=', rawurldecode($chunk))
Copy link
Member

@jsor jsor Jun 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)`?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point 👍

@andig
Copy link
Contributor

andig commented Sep 17, 2017

@WyriHaximus superseded by #222?

@WyriHaximus
Copy link
Member Author

Superseded by #220 or #222

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants