Welcome Guest, Not a member yet? Register   Sign In
CURLrequest - getShared does't work
#1

(This post was last modified: 08-26-2022, 06:41 AM by 5flex.)

I have installed CI 4.2.4

I make CURL request and set headers as:
PHP Code:
$CURL = \Config\Services::curlrequest(['headers' => $this->CURL_headers]); 

After this request I call another method in my Controller and make second request
PHP Code:
$CURL = \Config\Services::curlrequest(['headers' => $this->pleskHeaders]); 

In this case a headers is different
In my app/Config/CURLrequest.php option $shareOptions is OFF (= false) but I always give error 401 Unauthorized because headers in new request is not updated and always stay is old. It's bug or not? How to fix this problem?

Thx!

P.S.
I solved the problem by setting the last argument to false.
$CURL = \Config\Services::curlrequest(['headers' => $this->pleskHeaders], null, null, false);

Perhaps it's time to stop this torment and finally go to Laravel. These are really childish problems that drag on for months and years. You write in the official documentation that the $shareOptions option solves this problem, but in fact it doesn't! Why write something that didn't pass the tests?
Reply
#2

That is not a bug.

1. Services returns basically shared instance. So the second options are ignored. It may be a bit tricky, so added the explanation in the User Guide. See https://codeigniter4.github.io/CodeIgnit...t-a-servic

2. CURLRequest never reset options passed to the constructor. See the Note: https://codeigniter4.github.io/CodeIgnit...he-library
Reply




Theme © iAndrew 2016 - Forum software by © MyBB