File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 3030
3131class Tiny_Compress_Client extends Tiny_Compress {
3232
33+ /**
34+ * API request timeout in seconds.
35+ *
36+ * @since 3.6.8
37+ * @var int
38+ */
39+ const API_TIMEOUT = 10 ;
40+
3341 private $ last_error_code = 0 ;
3442 private $ last_message = '' ;
3543 private $ proxy ;
@@ -176,6 +184,10 @@ private function set_request_options( $client ) {
176184 $ property ->setAccessible ( true );
177185 $ options = $ property ->getValue ( $ client );
178186
187+ // Set API request timeout to prevent indefinite hanging
188+ $ options [ CURLOPT_TIMEOUT ] = self ::API_TIMEOUT ;
189+ $ options [ CURLOPT_CONNECTTIMEOUT ] = self ::API_TIMEOUT ;
190+
179191 if ( TINY_DEBUG ) {
180192 $ file = fopen ( dirname ( __FILE__ ) . '/curl.log ' , 'w ' );
181193 if ( is_resource ( $ file ) ) {
@@ -194,5 +206,7 @@ private function set_request_options( $client ) {
194206 $ options [ CURLOPT_PROXYUSERPWD ] = $ this ->proxy ->authentication ();
195207 }
196208 }
209+
210+ $ property ->setValue ( $ client , $ options );
197211 }
198212}
You can’t perform that action at this time.
0 commit comments