@@ -42,7 +42,14 @@ class CURLRequest extends Request
4242 *
4343 * @var array
4444 */
45- protected $ config = [
45+ protected $ config ;
46+
47+ /**
48+ * The default setting values
49+ *
50+ * @var array
51+ */
52+ private $ defaultConfig = [
4653 'timeout ' => 0.0 ,
4754 'connect_timeout ' => 150 ,
4855 'debug ' => false ,
@@ -79,6 +86,13 @@ class CURLRequest extends Request
7986 */
8087 private $ defaultOptions ;
8188
89+ /**
90+ * Whether share options between requests or not.
91+ *
92+ * @var bool
93+ */
94+ private $ shareOptions ;
95+
8296 /**
8397 * Takes an array of options to set the following possible class properties:
8498 *
@@ -102,6 +116,8 @@ public function __construct(App $config, URI $uri, ?ResponseInterface $response
102116 $ this ->response = $ response ;
103117 $ this ->baseURI = $ uri ->useRawQueryString ();
104118 $ this ->defaultOptions = $ options ;
119+ $ this ->config = $ this ->defaultConfig ;
120+ $ this ->shareOptions = $ config ->CURLRequestShareOptions ?? true ;
105121
106122 $ this ->parseOptions ($ options );
107123 }
@@ -122,15 +138,24 @@ public function request($method, string $url, array $options = []): ResponseInte
122138
123139 $ this ->send ($ method , $ url );
124140
141+ if ($ this ->shareOptions === false ) {
142+ $ this ->resetOptions ();
143+ }
144+
145+ return $ this ->response ;
146+ }
147+
148+ private function resetOptions ()
149+ {
125150 // Reset headers
126151 $ this ->headers = [];
127152 $ this ->headerMap = [];
128- // Reset unshared configs
129- unset($ this ->config ['multipart ' ], $ this ->config ['form_params ' ]);
153+
154+ // Reset configs
155+ $ this ->config = $ this ->defaultConfig ;
156+
130157 // Set the default options for next request
131158 $ this ->parseOptions ($ this ->defaultOptions );
132-
133- return $ this ->response ;
134159 }
135160
136161 /**
0 commit comments