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

Phalcon\Http\Request::getRawBody() empties the raw body content #1091

Closed
mapsi opened this issue Aug 15, 2013 · 3 comments
Closed

Phalcon\Http\Request::getRawBody() empties the raw body content #1091

mapsi opened this issue Aug 15, 2013 · 3 comments

Comments

@mapsi
Copy link

mapsi commented Aug 15, 2013

Hello y'all,

Since v1.2.1 Phalcon\Http\Request::getRawBody() empties the raw body content.

What does this mean?
If from a terminal I fire ...

curl -XGET 'http://server/controller/action' -d '{"query":[["george","alan", "thomas"]]}'

and in my application I have ...

var_dump($app->request->getRawBody(), $app->request->getRawBody());exit;

In Phalcon v1.2.0 I would get ...

string(37) "{"query":["george","alan","thomas"]]}"
string(37) "{"query":["george","alan","thomas"]]}"

In Phalcon v1.2.1+ I get ...

string(37) "{"query":["george","alan","thomas"]]}"
string(0) ""

and this stands true for available all post v1.2.0 versions.

As this is not a documented feature, I can only assume it's bug.

If I remember correctly, I read somewhere that the JSON library has been changed in the post v1.2.0 versions so maybe this is the cause of the issue?

Many thanks in advance,
Angel

@dreamsxin
Copy link
Contributor

Because you use the GET, the first data read from the stream, the second stream has no data, and if you use POST is no problem, because the POST data has been read, will stored in SG (request_info). Raw_post_data.

In Phalcon 1.2.0,Use the property _rawBody to store the data.

I do not know better that way, and so @phalcon to answer.

@ghost
Copy link

ghost commented Aug 16, 2013

That's not a JSON bug, this is my fault. I did not assume that you will try to access raw POST data in GET request and this is why one property was optimized away.

I'll try to revert back the original behavior

@ghost ghost mentioned this issue Aug 16, 2013
phalcon pushed a commit that referenced this issue Aug 16, 2013
@phalcon
Copy link
Collaborator

phalcon commented Aug 17, 2013

This was fixed in #1091

@phalcon phalcon closed this as completed Aug 17, 2013
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

No branches or pull requests

2 participants