@@ -11,10 +11,17 @@ class Curl implements RequestResolverInterface
1111 protected $ result ;
1212 protected $ url ;
1313 protected $ config = array (
14- 'userAgent ' => 'Embed PHP Library ' ,
15- 'maxRedirections ' => 20 ,
16- 'connectionTimeout ' => 10 ,
17- 'timeout ' => 10 ,
14+ CURLOPT_RETURNTRANSFER => true ,
15+ CURLOPT_FOLLOWLOCATION => true ,
16+ CURLOPT_MAXREDIRS => 20 ,
17+ CURLOPT_CONNECTTIMEOUT => 10 ,
18+ CURLOPT_TIMEOUT => 10 ,
19+ CURLOPT_SSL_VERIFYPEER => false ,
20+ CURLOPT_SSL_VERIFYHOST => false ,
21+ CURLOPT_ENCODING => '' ,
22+ CURLOPT_AUTOREFERER => true ,
23+ CURLOPT_USERAGENT => 'Embed PHP Library ' ,
24+ CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4 ,
1825 );
1926
2027 public static $ binaryContentTypes = array (
@@ -125,32 +132,20 @@ protected function getResult($name)
125132 */
126133 protected function resolve ()
127134 {
128- $ connection = curl_init ();
135+ $ this ->content = '' ;
136+ $ this ->isBinary = null ;
129137
130138 $ tmpCookies = str_replace ('// ' , '/ ' , sys_get_temp_dir ().'/embed-cookies.txt ' );
131139
140+ $ connection = curl_init ();
141+
132142 curl_setopt_array ($ connection , array (
133143 CURLOPT_URL => $ this ->url ,
134- CURLOPT_RETURNTRANSFER => true ,
135- CURLOPT_FOLLOWLOCATION => true ,
136- CURLOPT_MAXREDIRS => $ this ->config ['maxRedirections ' ],
137- CURLOPT_CONNECTTIMEOUT => $ this ->config ['connectionTimeout ' ],
138- CURLOPT_TIMEOUT => $ this ->config ['timeout ' ],
139- CURLOPT_SSL_VERIFYPEER => false ,
140- CURLOPT_SSL_VERIFYHOST => false ,
141- CURLOPT_ENCODING => '' ,
142- CURLOPT_AUTOREFERER => true ,
143144 CURLOPT_COOKIEJAR => $ tmpCookies ,
144145 CURLOPT_COOKIEFILE => $ tmpCookies ,
145- CURLOPT_USERAGENT => $ this ->config ['userAgent ' ],
146- CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4 ,
147- ));
148-
149- $ this ->content = '' ;
150- $ this ->isBinary = null ;
151-
152- curl_setopt ($ connection , CURLOPT_HEADERFUNCTION , array ($ this , 'headerCallback ' ));
153- curl_setopt ($ connection , CURLOPT_WRITEFUNCTION , array ($ this , 'writeCallback ' ));
146+ CURLOPT_HEADERFUNCTION => array ($ this , 'headerCallback ' ),
147+ CURLOPT_WRITEFUNCTION => array ($ this , 'writeCallback ' ),
148+ ) + $ this ->config );
154149
155150 curl_exec ($ connection );
156151
0 commit comments