Welcome Guest, Not a member yet? Register   Sign In
CURL and clearing query after send
#1
Question 

Hi,

I'm using `curlrequest` but I found a problem. When we use a service `curlrequest` we could set an option for the client. For API which I'm trying to call auth is passed as a query params so I set options like this:

PHP Code:
        $client = \Config\Services::curlrequest([
            'baseURI' => 'API',
            'query' => [
                'key' => 'key',
                'token' => 'token'
            ]
        ]); 

and everything works ok for the first request but next don't get that `query` option because it's cleared in `system/HTTP/CURLRequest.php:429`. It's this part of code:

PHP Code:
    public function send(string $methodstring $url)
    {
        
// Reset our curl options so we're on a fresh slate.
        
$curl_options = [];

        if (! empty(
$this->config['query']) && is_array($this->config['query']))
        {
            
// This is likely too naive a solution.
            // Should look into handling when $url already
            // has query vars on it.
            
$url .= '?' http_build_query($this->config['query']);
            unset(
$this->config['query']);
        } 

and I'm not sure if it's proper behavior?
Reply


Messages In This Thread
CURL and clearing query after send - by Michal_PB1 - 08-25-2020, 02:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB