@@ -92,6 +92,10 @@ public function request(string $method, string $url, array $options = []): Respo
92
92
$ scheme = $ url ['scheme ' ];
93
93
$ authority = $ url ['authority ' ];
94
94
$ host = parse_url ($ authority , \PHP_URL_HOST );
95
+ $ proxy = $ options ['proxy ' ]
96
+ ?? ('https: ' === $ url ['scheme ' ] ? $ _SERVER ['https_proxy ' ] ?? $ _SERVER ['HTTPS_PROXY ' ] ?? null : null )
97
+ // Ignore HTTP_PROXY except on the CLI to work around httpoxy set of vulnerabilities
98
+ ?? $ _SERVER ['http_proxy ' ] ?? (\in_array (\PHP_SAPI , ['cli ' , 'phpdbg ' ], true ) ? $ _SERVER ['HTTP_PROXY ' ] ?? null : null ) ?? $ _SERVER ['all_proxy ' ] ?? $ _SERVER ['ALL_PROXY ' ] ?? null ;
95
99
$ url = implode ('' , $ url );
96
100
97
101
if (!isset ($ options ['normalized_headers ' ]['user-agent ' ])) {
@@ -107,7 +111,7 @@ public function request(string $method, string $url, array $options = []): Respo
107
111
\CURLOPT_MAXREDIRS => 0 < $ options ['max_redirects ' ] ? $ options ['max_redirects ' ] : 0 ,
108
112
\CURLOPT_COOKIEFILE => '' , // Keep track of cookies during redirects
109
113
\CURLOPT_TIMEOUT => 0 ,
110
- \CURLOPT_PROXY => $ options [ ' proxy ' ] ,
114
+ \CURLOPT_PROXY => $ proxy ,
111
115
\CURLOPT_NOPROXY => $ options ['no_proxy ' ] ?? $ _SERVER ['no_proxy ' ] ?? $ _SERVER ['NO_PROXY ' ] ?? '' ,
112
116
\CURLOPT_SSL_VERIFYPEER => $ options ['verify_peer ' ],
113
117
\CURLOPT_SSL_VERIFYHOST => $ options ['verify_host ' ] ? 2 : 0 ,
@@ -404,8 +408,15 @@ private static function createRedirectResolver(array $options, string $host): \C
404
408
}
405
409
406
410
$ url = self ::parseUrl (curl_getinfo ($ ch , \CURLINFO_EFFECTIVE_URL ));
411
+ $ url = self ::resolveUrl ($ location , $ url );
407
412
408
- return implode ('' , self ::resolveUrl ($ location , $ url ));
413
+ curl_setopt ($ ch , \CURLOPT_PROXY , $ options ['proxy ' ]
414
+ ?? ('https: ' === $ url ['scheme ' ] ? $ _SERVER ['https_proxy ' ] ?? $ _SERVER ['HTTPS_PROXY ' ] ?? null : null )
415
+ // Ignore HTTP_PROXY except on the CLI to work around httpoxy set of vulnerabilities
416
+ ?? $ _SERVER ['http_proxy ' ] ?? (\in_array (\PHP_SAPI , ['cli ' , 'phpdbg ' ], true ) ? $ _SERVER ['HTTP_PROXY ' ] ?? null : null ) ?? $ _SERVER ['all_proxy ' ] ?? $ _SERVER ['ALL_PROXY ' ] ?? null
417
+ );
418
+
419
+ return implode ('' , $ url );
409
420
};
410
421
}
411
422
}
0 commit comments