aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2020-03-22 19:38:01 +0100
committerGitHub <noreply@github.com>2020-03-22 19:38:01 +0100
commit6675f9b403b39949526e1fcce306e4adb32574b3 (patch)
tree4afc3140fef9b57a2aaeada95c5e37e5b593f214 /lib/private
parentea6601a2fc781175cf271f707e486f2fb3da5d57 (diff)
parent98d6415264c1f211f50ee7a0b336103a488c3608 (diff)
downloadnextcloud-server-6675f9b403b39949526e1fcce306e4adb32574b3.tar.gz
nextcloud-server-6675f9b403b39949526e1fcce306e4adb32574b3.zip
Merge pull request #17684 from mlatief/support-no-proxy
Add support for GuzzleHTTP 'no' proxy
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Http/Client/Client.php41
1 files changed, 34 insertions, 7 deletions
diff --git a/lib/private/Http/Client/Client.php b/lib/private/Http/Client/Client.php
index c52d90ff8ec..657bfb8d536 100644
--- a/lib/private/Http/Client/Client.php
+++ b/lib/private/Http/Client/Client.php
@@ -65,12 +65,20 @@ class Client implements IClient {
}
private function buildRequestOptions(array $options): array {
+ $proxy = $this->getProxyUri();
+
$defaults = [
- RequestOptions::PROXY => $this->getProxyUri(),
RequestOptions::VERIFY => $this->getCertBundle(),
RequestOptions::TIMEOUT => 30,
];
+ // Only add RequestOptions::PROXY if Nextcloud is explicitly
+ // configured to use a proxy. This is needed in order not to override
+ // Guzzle default values.
+ if($proxy !== null) {
+ $defaults[RequestOptions::PROXY] = $proxy;
+ }
+
$options = array_merge($defaults, $options);
if (!isset($options[RequestOptions::HEADERS]['User-Agent'])) {
@@ -96,11 +104,21 @@ class Client implements IClient {
}
/**
- * Get the proxy URI
+ * Returns a null or an associative array specifiying the proxy URI for
+ * 'http' and 'https' schemes, in addition to a 'no' key value pair
+ * providing a list of host names that should not be proxied to.
+ *
+ * @return array|null
+ *
+ * The return array looks like:
+ * [
+ * 'http' => 'username:password@proxy.example.com',
+ * 'https' => 'username:password@proxy.example.com',
+ * 'no' => ['foo.com', 'bar.com']
+ * ]
*
- * @return string|null
*/
- private function getProxyUri(): ?string {
+ private function getProxyUri(): ?array {
$proxyHost = $this->config->getSystemValue('proxy', '');
if ($proxyHost === '' || $proxyHost === null) {
@@ -108,12 +126,21 @@ class Client implements IClient {
}
$proxyUserPwd = $this->config->getSystemValue('proxyuserpwd', '');
+ if ($proxyUserPwd !== '' && $proxyUserPwd !== null) {
+ $proxyHost = $proxyUserPwd . '@' . $proxyHost;
+ }
+
+ $proxy = [
+ 'http' => $proxyHost,
+ 'https' => $proxyHost,
+ ];
- if ($proxyUserPwd === '' || $proxyUserPwd === null) {
- return $proxyHost;
+ $proxyExclude = $this->config->getSystemValue('proxyexclude', []);
+ if ($proxyExclude !== [] && $proxyExclude !== null) {
+ $proxy['no'] = $proxyExclude;
}
- return $proxyUserPwd . '@' . $proxyHost;
+ return $proxy;
}
/**