forked from ixudra/curl
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
don't create http_build_query from POSTFIELDS array
- Loading branch information
Showing
1 changed file
with
4 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
781195b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate what exactly it is you are doing here? Is there an error in the package that is fixed by this? Can you show me a use case?
781195b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all, thanks for your great package!
My use case: I had to send a file with the curl request (using CURLFile) and found out curl doesn't set the correct header when http_build_query is used instead of an array (like in your forgeOptions function).
According to PHP curl docs on CURLOPT_POSTFIELDS (http://php.net/manual/en/function.curl-setopt.php):
"If value is an array, the Content-Type header will be set to multipart/form-data. As of PHP 5.2.0, value must be an array if files are passed to this option with the @ prefix. As of PHP 5.5.0, the @ prefix is deprecated and files can be sent using CURLFile."
I was a bit in a hurry so just quick-fixed it for my use case for now... not sure if it can cause problems for other use cases?
781195b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to me this would be a good use case for a utility method. Could you send me the code that you use to upload the file using the package?
781195b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
781195b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I've added an issue in my repo and I hope to tackle it soon (no promises).
Btw, did you know you can uptimize your code by taking advantage of the fluid query builder?
Just saying :-)
781195b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Jan, looking forward to it!
You're right that this piece of code could be optimized with a fluid query syntax. In the original code I'm using if statements to check wether withData should be included or not. Also makes debugging a little bit easier ;-)
781195b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @kaluax & @elimentz,
i added the pull request to ixudra#21