-
Notifications
You must be signed in to change notification settings - Fork 51
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
cURL.php prepareRequest - wrong behavior #61
Comments
I recently implemented this behaviour so maybe I can help. This is important for JSON communication, because empty arrays and empty objects are encoded to '[]' and '{}' respectively, and this is NON-empty data, hasData MUST be true, and CURLOPT_POSTFIELDS MUST be sent. Please state your exact usage, the expected result, and the actual result, so that we may find a universal solution. |
What @djcvijic wrote is indeed true! @akoevroman what version of the library are you using? This should be fixed in 1.4.5 or higher. I pushed a commit for the |
Version 1.4.6 Example:
so then we go to lib
array() by default then Finaly:
maybe... i did something wrong? Of course, "'[]' returned" is not a critical error but some API denied empty array in POST fields and return a response that appropriate data are expected. P.S. Maybe if I will use 3rd parameter and set it to '' it will work, but this is not obvious logic. And i did not try it. |
That's an annoying bug. See the commit message of a2809a2 for more information. I've tagged |
Yes, the recent fix I made was to cover POST-like request methods, but then GET was broken in the process. 1.4.7 looks good to me. |
In several cases: $request->hasData() return true for empty(default) array of data.
This happens if $request->encodeData() return string '[]'
In this case, empty CURLOPT_POSTFIELDS are sent.
Also Request.php -> encodeData function has $encoding variable which is not defined.
The text was updated successfully, but these errors were encountered: