@@ -375,10 +375,11 @@ public static function wrapResult($result = '', $queryObject = '')
375375     *  
376376     * @return Result 
377377     * */ 
378-     public  static  function  contentstackRequest ($ queryObject'' , $ type'' )
378+     public  static  function  contentstackRequest ($ stack ,  $ queryObject'' , $ type'' ,  $ count  =  0 )
379379    {
380-         $ server_output'' ;
381-         
380+         $ retryDelay$ stackretryDelay ;
381+         $ retryLimit$ stackretryLimit ;
382+         $ errorRetry$ stackerrorRetry ;
382383        if  ($ queryObject
383384            if  (Utility::isLivePreview ($ queryObject
384385                $ queryObject_query ['live_preview ' ] = ($ queryObjectcontentType ->stack ->live_preview ['live_preview ' ] ?? 'init ' );
@@ -399,30 +400,67 @@ public static function contentstackRequest($queryObject = '', $type = '')
399400            if  ($ Headers"branch " ] !== ''  && $ Headers"branch " ] !== "undefined " ) {
400401                $ request_headers'branch:  ' .$ Headers"branch " ];
401402            }
403+ 
404+             $ proxy_details$ stackproxy ;
405+             $ timeout$ stacktimeout ;
406+ 
402407            curl_setopt ($ httpCURLOPT_HTTPHEADER , $ request_headers
403408
404409            curl_setopt ($ httpCURLOPT_HEADER , false );
405410            // setting the GET request 
406411            curl_setopt ($ httpCURLOPT_CUSTOMREQUEST , "GET " );
407412            // receive server response ... 
408413            curl_setopt ($ httpCURLOPT_RETURNTRANSFER , true );
409-             $ responsecurl_exec ($ http
414+             // set the cURL time out 
415+             curl_setopt ($ httpCURLOPT_TIMEOUT_MS , $ timeout
416+ 
417+             if (array_key_exists ("url " ,$ proxy_detailsarray_key_exists ("port " ,$ proxy_details
418+                 if ($ proxy_details'url ' ] != ''  && $ proxy_details'port ' ] != '' ) {
410419
420+                     // Set the proxy IP 
421+                     curl_setopt ($ httpCURLOPT_PROXY , $ proxy_details'url ' ]);
422+                     // Set the port 
423+                     curl_setopt ($ httpCURLOPT_PROXYPORT , $ proxy_details'port ' ]);
424+                     
425+                     if (array_key_exists ("username " ,$ proxy_detailsarray_key_exists ("password " ,$ proxy_details
426+                         if ($ proxy_details'username ' ] != ''  && $ proxy_details'password ' ] != '' ) {
427+ 
428+                             $ proxyauth$ proxy_details'username ' ].": " .$ proxy_details'password ' ];
429+                             // Set the username and password 
430+                             curl_setopt ($ httpCURLOPT_PROXYUSERPWD , $ proxyauth
431+                             
432+                         }
433+                     }
434+                 }
435+             }
436+             
437+             $ responsecurl_exec ($ http
411438            // status code extraction 
412439            $ httpcodecurl_getinfo ($ httpCURLINFO_HTTP_CODE );
413- 
440+              
414441            // close the curl             
415442            curl_close ($ http
416-             if  ($ httpcode199  && $ httpcode300 ) {
417-                 // wrapper the server result 
418-                 $ responsewrapResult ($ response$ queryObject
443+             if (in_array ($ httpcode$ errorRetry
444+                 if ($ count$ retryLimit
445+                     $ retryDelayround ($ retryDelay1000 ); //converting retry_delay from milliseconds into seconds 
446+                     sleep ($ retryDelay//sleep method requires time in seconds 
447+                     $ count1 ;
448+                     return  Utility::contentstackRequest ($ stack$ queryObject$ type$ count
449+                 }
419450            } else  {
420-                 throw  new  CSException ($ response$ httpcode
451+                 if  ($ httpcode199  && $ httpcode300 ) {
452+                     // wrapper the server result 
453+                     $ responsewrapResult ($ response$ queryObject
454+                 }
455+                 else {
456+                     throw  new  CSException ($ response$ httpcode
457+                 }
421458            }
422459        }
423460        return  $ response
424461    }
425462
463+ 
426464    /** 
427465     * Validate the key is set or not 
428466     *  
0 commit comments