File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 3434
3535// Init curl
3636$ curl = curl_init ();
37+ $ maxredirs = $ opts [CURLOPT_MAXREDIRS ] ?? 20 ;
3738do
3839{
3940 // Set generic options
4041 curl_setopt_array ($ curl , [
4142 CURLOPT_URL => $ url ,
4243 CURLOPT_HTTPHEADER => $ headers ,
43- CURLOPT_HEADER => TRUE ,
44- CURLOPT_TIMEOUT => $ curl_timeout ?? 30 ,
45- CURLOPT_FOLLOWLOCATION => TRUE ,
46- CURLOPT_MAXREDIRS => $ curl_maxredirs ?? 10 ,
44+ CURLOPT_HEADER => true ,
45+ ] + $ opts + [
46+ CURLOPT_FOLLOWLOCATION => true ,
47+ CURLOPT_MAXREDIRS => $ maxredirs ,
4748 ]);
4849
4950 // Method specific options
5051 switch ($ method )
5152 {
5253 case 'HEAD ' :
53- curl_setopt ($ curl , CURLOPT_NOBODY , TRUE );
54+ curl_setopt ($ curl , CURLOPT_NOBODY , true );
5455 break ;
5556
5657 case 'GET ' :
Original file line number Diff line number Diff line change @@ -13,10 +13,13 @@ class CrossOriginProxy
1313 * Proxies the incoming request and outputs the response, including headers.
1414 *
1515 * @param whitelist Array of acceptable request URLs.
16- * @param curl_timeout Timeout for the request.
17- * @param curl_maxredirs Maximum number of allowed redirects.
16+ * @param curl_opts Array of cURL options to add to proxy request.
17+ * @param zlib Value for zlib.output_compression.
18+ *
19+ * @see http://php.net/manual/function.curl-setopt.php
20+ * @see http://php.net/manual/zlib.configuration.php
1821 */
19- public static function proxy (array $ whitelist = [], int $ curl_timeout = 30 , int $ curl_maxredirs = 10 )
22+ public static function proxy (array $ whitelist = [], array $ curl_opts = [], $ zlib = ' On ' )
2023 {
2124 require dirname (__FILE__ ).DIRECTORY_SEPARATOR .'.. ' .DIRECTORY_SEPARATOR .'proxy.php ' ;
2225 }
You can’t perform that action at this time.
0 commit comments