Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/richdocuments.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2020-11-24 16:26:21 +0300
committerSzymon Kłos <szymon.klos@collabora.com>2020-11-24 16:26:51 +0300
commitca705a471ecd78b08a6cd097e44b8e7cb769ed1b (patch)
tree38f41fabcfc041cf72bd6184e8416a96c9a2a11f /lib
parent5a83a1b7281877a8dfba55038206c8567f6dbffd (diff)
Move proxy status check to the separate function
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/WOPI/DiscoveryManager.php44
1 files changed, 30 insertions, 14 deletions
diff --git a/lib/WOPI/DiscoveryManager.php b/lib/WOPI/DiscoveryManager.php
index 5a2fd057..d8d70b58 100644
--- a/lib/WOPI/DiscoveryManager.php
+++ b/lib/WOPI/DiscoveryManager.php
@@ -77,18 +77,43 @@ class DiscoveryManager {
$options['verify'] = false;
}
- // first load with proxy can take some time - increase timeout in that case
+ if ($this->isProxyStarting($wopiDiscovery))
+ $options['timeout'] = 180;
+
+ try {
+ return $client->get($wopiDiscovery, $options);
+ } catch (\Exception $e) {
+ throw $e;
+ }
+ }
+
+ public function refetch() {
+ $this->cache->remove('discovery');
+ $this->discovery = null;
+ }
+
+ /**
+ * @return boolean indicating if proxy.php is in initialize or false otherwise
+ */
+ private function isProxyStarting($url) {
$usesProxy = false;
- $proxyPos = strrpos($wopiDiscovery, 'proxy.php');
+ $proxyPos = strrpos($url, 'proxy.php');
if ($proxyPos === false)
$usesProxy = false;
else
$usesProxy = true;
if ($usesProxy === true) {
- $statusUrl = substr($wopiDiscovery, 0, $proxyPos);
+ $statusUrl = substr($url, 0, $proxyPos);
$statusUrl = $statusUrl . 'proxy.php?status';
+ $client = $this->clientService->newClient();
+ $options = ['timeout' => 5, 'nextcloud' => ['allow_local_address' => true]];
+
+ if ($this->config->getAppValue('richdocuments', 'disable_certificate_verification') === 'yes') {
+ $options['verify'] = false;
+ }
+
try {
$response = $client->get($statusUrl, $options);
@@ -98,7 +123,7 @@ class DiscoveryManager {
if ($body['status'] === 'starting'
|| $body['status'] === 'stopped'
|| $body['status'] === 'restarting') {
- $options['timeout'] = 180;
+ return true;
}
}
} catch (\Exception $e) {
@@ -106,15 +131,6 @@ class DiscoveryManager {
}
}
- try {
- return $client->get($wopiDiscovery, $options);
- } catch (\Exception $e) {
- throw $e;
- }
- }
-
- public function refetch() {
- $this->cache->remove('discovery');
- $this->discovery = null;
+ return false;
}
}