File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 3737$ maxredirs = $ opts [CURLOPT_MAXREDIRS ] ?? 20 ;
3838do
3939{
40- // Set generic options
41- curl_setopt_array ($ curl , [
40+ // Set options
41+ curl_setopt_array ($ curl ,
42+ [
4243 CURLOPT_URL => $ url ,
4344 CURLOPT_HTTPHEADER => $ headers ,
4445 CURLOPT_HEADER => true ,
45- ] + ($ opts ??[]) + [
46+ ]
47+ + ($ curl_opts ??[]) +
48+ [
4649 CURLOPT_FOLLOWLOCATION => true ,
4750 CURLOPT_MAXREDIRS => $ maxredirs ,
4851 ]);
6871
6972 // Perform request
7073 ob_start ();
71- curl_exec ($ curl ) or http_response_code ( 500 ) and exit ( curl_error ( $ curl )) ;
74+ curl_exec ($ curl );
7275 $ out = ob_get_clean ();
7376
77+ // Light error handling
78+ // http://php.net/manual/en/curl.constants.php#117723
79+ if (curl_errno ($ curl ))
80+ switch (curl_errno ($ curl ))
81+ {
82+ case 7 :
83+ case 28 :
84+ http_response_code (504 );
85+
86+ default :
87+ exit (curl_error ($ curl ));
88+ }
89+
7490 // HACK: If for any reason redirection doesn't work, do it manually...
7591 $ url = curl_getinfo ($ curl , CURLINFO_REDIRECT_URL );
7692}
Original file line number Diff line number Diff line change 2626}
2727
2828// Call/Use the proxy
29- Geekality \CrossOriginProxy::proxy ($ whitelist );
29+ Geekality \CrossOriginProxy::proxy ($ whitelist, [ CURLOPT_TIMEOUT => 5 ] );
You can’t perform that action at this time.
0 commit comments