File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,6 +60,14 @@ class JsonRPCClient
6060 * @var boolean
6161 */
6262 private $ notification = false ;
63+
64+ /**
65+ * If false, requests will be forced to use fopen() instead.
66+ * This option is specific in case of cURL is callable but may not practically unsable.
67+ *
68+ * @var boolean
69+ */
70+ private $ enableCurl = true ;
6371
6472 /**
6573 * Takes the connection parameters
@@ -141,7 +149,7 @@ public function __call($method, $params)
141149 );
142150 $ context = stream_context_create ($ opts );
143151
144- if (is_callable ('curl_init ' )) {
152+ if ($ this -> enableCurl && is_callable ('curl_init ' )) {
145153 // use curl when available; solves problems with allow_url_fopen
146154 $ ch = curl_init ($ this ->url );
147155 curl_setopt ($ ch , CURLOPT_POST , 1 );
@@ -185,4 +193,20 @@ public function __call($method, $params)
185193 return true ;
186194 }
187195 }
196+
197+ /**
198+ * Enable cURL when performs a jsonRCP request.
199+ */
200+ public function enableCurl ()
201+ {
202+ $ this ->enableCurl = true ;
203+ }
204+
205+ /**
206+ * Disable cURL when performs a jsonRCP request.
207+ */
208+ public function disableCurl ()
209+ {
210+ $ this ->enableCurl = false ;
211+ }
188212}
You can’t perform that action at this time.
0 commit comments