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 17
17
*/
18
18
class CurlHttpAdapter implements HttpAdapterInterface
19
19
{
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
+
20
30
/**
21
31
* {@inheritDoc}
22
32
*/
@@ -29,6 +39,15 @@ public function getContent($url)
29
39
$ c = curl_init ();
30
40
curl_setopt ($ c , CURLOPT_RETURNTRANSFER , 1 );
31
41
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
+
32
51
$ content = curl_exec ($ c );
33
52
curl_close ($ c );
34
53
You can’t perform that action at this time.
0 commit comments