File tree 2 files changed +12
-8
lines changed
2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 34
34
35
35
// Init curl
36
36
$ curl = curl_init ();
37
+ $ maxredirs = $ opts [CURLOPT_MAXREDIRS ] ?? 20 ;
37
38
do
38
39
{
39
40
// Set generic options
40
41
curl_setopt_array ($ curl , [
41
42
CURLOPT_URL => $ url ,
42
43
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 ,
47
48
]);
48
49
49
50
// Method specific options
50
51
switch ($ method )
51
52
{
52
53
case 'HEAD ' :
53
- curl_setopt ($ curl , CURLOPT_NOBODY , TRUE );
54
+ curl_setopt ($ curl , CURLOPT_NOBODY , true );
54
55
break ;
55
56
56
57
case 'GET ' :
Original file line number Diff line number Diff line change @@ -13,10 +13,13 @@ class CrossOriginProxy
13
13
* Proxies the incoming request and outputs the response, including headers.
14
14
*
15
15
* @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
18
21
*/
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 ' )
20
23
{
21
24
require dirname (__FILE__ ).DIRECTORY_SEPARATOR .'.. ' .DIRECTORY_SEPARATOR .'proxy.php ' ;
22
25
}
You can’t perform that action at this time.
0 commit comments