Skip to content

Commit 88963ba

Browse files
committed
docs: add about CURLRequest $shareOptions
1 parent 8a5973b commit 88963ba

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

user_guide_src/source/libraries/curlrequest.rst

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ to change very little to move over to use Guzzle.
1919
in your version of PHP. This is a very common library that is typically available but not all hosts
2020
will provide it, so please check with your host to verify if you run into problems.
2121

22+
**********************
23+
Config for CURLRequest
24+
**********************
25+
26+
Sharing Options
27+
===============
28+
29+
Due to historical reasons, by default, the CURLRequest shares all the options between requests.
30+
If you send more than one request with an instance of the class,
31+
this behavior may cause an error request with unnecessary headers.
32+
33+
You can change the behavior by editing the following config parameter value in **app/Config/CURLRequest.php** to ``false``::
34+
35+
public $shareOptions = false;
36+
2237
*******************
2338
Loading the Library
2439
*******************
@@ -38,9 +53,11 @@ The options are described later in this document::
3853
];
3954
$client = \Config\Services::curlrequest($options);
4055

56+
.. note:: When ``$shareOptions`` is false, the default options passed to the class constructor will be used for all requests. Other options will be reset after sending a request.
57+
4158
When creating the class manually, you need to pass a few dependencies in. The first parameter is an
4259
instance of the ``Config\App`` class. The second parameter is a URI instance. The third
43-
parameter is a Response object. The fourth parameter is the optional ``$options`` array::
60+
parameter is a Response object. The fourth parameter is the optional default ``$options`` array::
4461

4562
$client = new \CodeIgniter\HTTP\CURLRequest(
4663
new \Config\App(),
@@ -70,6 +87,8 @@ a Response instance to you. This takes the HTTP method, the url and an array of
7087
'auth' => ['user', 'pass'],
7188
]);
7289

90+
.. note:: When ``$shareOptions`` is false, the options passed to the method will be used for the request. After sending the request, they will be cleared. If you want to use the options to all requests, pass the options in the constructor.
91+
7392
Since the response is an instance of ``CodeIgniter\HTTP\Response`` you have all of the normal information
7493
available to you::
7594

0 commit comments

Comments
 (0)