@@ -183,6 +183,7 @@ public static function remoteExecuteInit($command) {
183183 * @param http_method 'GET', 'POST', or 'DELETE'
184184 * @param suffix What to append to the base URL.
185185 * @param command The Command object, modelled as a hash.
186+ * @param curl Curl object
186187 * @param extra_opts key => value pairs of curl options for curl_setopt()
187188 */
188189
@@ -228,6 +229,8 @@ protected static function curl(http://github.com/%3C/div%3E%3C/code%3E%3C/div%3E%3C/td%3E%3C/tr%3E%3Ctr%20class=%22diff-line-row%22%3E%3Ctd%20data-grid-cell-id=%22diff-00b9e1a13f81274c9438ea7b8b04439deb5b9024e14273a54de0306d74d657f3-228-229-0%22%20data-selected=%22false%22%20role=%22gridcell%22%20style=%22background-color:var(--bgColor-default);text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative diff-line-number-neutral left-side">228
229 array (
229230 'Content-Type: application/json;charset=UTF-8 ' ,
230231 'Accept: application/json ' ));
232+ if ($ http_method === 'GET ' )
233+ curl_setopt ($ curl , CURLOPT_POST , false );
231234
232235 if ($ http_method === 'POST ' ) {
233236 curl_setopt ($ curl , CURLOPT_POST , true );
@@ -244,6 +247,7 @@ protected static function curl(http://github.com/%3C/div%3E%3C/code%3E%3C/div%3E%3C/td%3E%3C/tr%3E%3Ctr%20class=%22diff-line-row%22%3E%3Ctd%20data-grid-cell-id=%22diff-00b9e1a13f81274c9438ea7b8b04439deb5b9024e14273a54de0306d74d657f3-244-247-0%22%20data-selected=%22false%22%20role=%22gridcell%22%20style=%22background-color:var(--bgColor-default);text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative diff-line-number-neutral left-side">244
247
245248 $ raw_results = trim (curl_exec ($ curl ));
246249 $ info = curl_getinfo ($ curl );
250+ self ::reset_curl_options ($ curl , $ http_method , $ params , $ extra_opts );
247251
248252 if ($ error = curl_error ($ curl )) {
249253 $ msg = sprintf (
@@ -278,10 +282,36 @@ protected static function curl(http://github.com/%3C/div%3E%3C/code%3E%3C/div%3E%3C/td%3E%3C/tr%3E%3Ctr%20class=%22diff-line-row%22%3E%3Ctd%20data-grid-cell-id=%22diff-00b9e1a13f81274c9438ea7b8b04439deb5b9024e14273a54de0306d74d657f3-278-282-0%22%20data-selected=%22false%22%20role=%22gridcell%22%20style=%22background-color:var(--bgColor-default);text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative diff-line-number-neutral left-side">278
282 return array ('value ' => $ value , 'info ' => $ info , 'sessionId ' => $ sessionId );
279283 }
280284
285+ /**
286+ * Reset curl options after current request.
287+ * @param curl curl object
288+ * @param http_method 'GET', 'POST' or 'DELETE'
289+ * @param params command parameters
290+ * @param extra_opts key => value pairs of curl options for curl_setopt()
291+ */
292+
293+ protected static function reset_curl_options ($ curl , $ http_method , $ params , $ extra_opts ) {
294+ if ($ http_method === 'POST ' ) {
295+ curl_setopt ($ curl , CURLOPT_POST , false );
296+ if ($ params && is_array ($ params )) {
297+ curl_setopt ($ curl , CURLOPT_POSTFIELDS , "{} " );
298+ }
299+ } else if ($ http_method == 'DELETE ' ) {
300+ curl_setopt ($ curl , CURLOPT_CUSTOMREQUEST , '' );
301+ }
302+
303+ foreach ($ extra_opts as $ option => $ value ) {
304+ curl_setopt ($ curl , $ option , '' );
305+ }
306+ }
307+
281308 public function getSessionID () {
282309 return $ this ->sessionID ;
283310 }
284311
312+ /**
313+ * Close curl connection
314+ */
285315 public function close (){
286316 curl_close ($ this ->curl );
287317 }
0 commit comments