File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 1717 */
1818class CurlHttpAdapter implements HttpAdapterInterface
1919{
20+ private $ timeout ;
21+
22+ private $ connectTimeout ;
23+
24+ public function __construct ($ timeout = null , $ connectTimeout = null )
25+ {
26+ $ this ->timeout = $ timeout ;
27+ $ this ->connectTimeout = $ connectTimeout ;
28+ }
29+
2030 /**
2131 * {@inheritDoc}
2232 */
@@ -29,6 +39,15 @@ public function getContent($url)
2939 $ c = curl_init ();
3040 curl_setopt ($ c , CURLOPT_RETURNTRANSFER , 1 );
3141 curl_setopt ($ c , CURLOPT_URL , $ url );
42+
43+ if ($ this ->timeout ) {
44+ curl_setopt ($ c , CURLOPT_TIMEOUT , $ this ->timeout );
45+ }
46+
47+ if ($ this ->connectTimeout ) {
48+ curl_setopt ($ c , CURLOPT_CONNECTTIMEOUT , $ this ->connectTimeout );
49+ }
50+
3251 $ content = curl_exec ($ c );
3352 curl_close ($ c );
3453
You can’t perform that action at this time.
0 commit comments