You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I was trying to build a new plugin I was stopped by the native fetch function due to the code logic being dated. Many things need improvement in the code and today I've hit many issues with the function itself so I had to make a custom implementation.
There is a wrong/useless part that prevents fetching data from sites with custom host:port values like https://somesite:8443/api/data.json
I couldn't set a method if API requests PUT or DELETE. There needs to be something like the 4th param with @param $method = "GET"
// Set the method
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, strtoupper($method));
// Set the data if it's a PUT or POST requestif ($method == 'PUT' || $method == 'POST')
{
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
}
This function overall is very powerful, but very dated and there is no reason not to update it. As it hooks in many plugins, we can jus add optional parameters on the function's end and meet today's standards.
The text was updated successfully, but these errors were encountered:
As I was trying to build a new plugin I was stopped by the native fetch function due to the code logic being dated. Many things need improvement in the code and today I've hit many issues with the function itself so I had to make a custom implementation.
host:port
values likehttps://somesite:8443/api/data.json
@param $method = "GET"
@param $headers = array()
.And set equivalent for fsocks headers in this part
Also, this part is redundant as well and should be removed if someone set https and port 80, there must be a reason for that.
This function overall is very powerful, but very dated and there is no reason not to update it. As it hooks in many plugins, we can jus add optional parameters on the function's end and meet today's standards.
The text was updated successfully, but these errors were encountered: