-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
getRawBody different after instantiate new Request twice #11958
Comments
@javierfrancia Could you please check 2.0.13? |
Why would you instantiate Request at first place? You can use the one from memory (IoC services.php -> DI). Then, what is the point of instantiating it two times in a row, during same app runtime? HTTP is stateless protocol, i.e. every new request from a client is literally - new request. I guess that second time you instantiate the Request object, it will be a fresh instance (that's why we use shared services in IoC container) and thus will be missing any data from HTTP client request. |
Thanks for your comment @stamster. I totally agree with that. It is weird that when you do a new Request() yo are able to get the details of a request. I am quite amateur with Phalcon but following the documentation: https://docs.phalconphp.com/en/latest/reference/request.html. In order to get the details of the request you instantiate it. It looks like it is an intended behaviour of this Object. In my example, I am making a request to my service. Thanks @sergeyklay I will have a look at 2.0.13 but will then ask to change phalcon version on a production environment from 2.0.7 to 2.0.13. This will need to be prioritised in the pipeline. |
Yes, but that example is if you only use Request as a stand-alone component. If you instantiate it again manually it will obviously work, i.e. it will re-read raw request from PHP superglobals, but on second instance it will empty buffers. |
Thanks @stamster for the explanation. |
Hi,
I believe this could be related to the issue:
#10694
Class Phalcon\Http\Reques
When I am instantiating twice new Request the second time the method getRawBody() returns empty value in a PUT Request.
E.G:
$request = new Request();
$data = $request->getRawBody();
syslog(LOG_INFO,' DATA 1: '.var_export($data,true));
$request = new Request();
$data = $request->getRawBody();
syslog(LOG_INFO,' DATA 2: '.var_export($data,true));
This is happening in version:
phalcon => enabled
Author => Phalcon Team and contributors
Version => 2.0.7
Build Date => Sep 4 2015 16:08:04
Powered by Zephir => Version 0.7.1b
The text was updated successfully, but these errors were encountered: