1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* ownCloud - Calendar App |
4
|
|
|
* |
5
|
|
|
* @author Georg Ehrke |
6
|
|
|
* @copyright 2016 Georg Ehrke <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This library is free software; you can redistribute it and/or |
9
|
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
10
|
|
|
* License as published by the Free Software Foundation; either |
11
|
|
|
* version 3 of the License, or any later version. |
12
|
|
|
* |
13
|
|
|
* This library is distributed in the hope that it will be useful, |
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
17
|
|
|
* |
18
|
|
|
* You should have received a copy of the GNU Affero General Public |
19
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
20
|
|
|
* |
21
|
|
|
*/ |
22
|
|
|
namespace OCA\Calendar\Controller; |
23
|
|
|
|
24
|
|
|
use GuzzleHttp\Exception\ClientException; |
25
|
|
|
use OCA\Calendar\Http\StreamResponse; |
26
|
|
|
use OCP\AppFramework\Http\JSONResponse; |
27
|
|
|
|
28
|
|
|
use OCP\AppFramework\Controller; |
29
|
|
|
use OCP\Http\Client\IClientService; |
30
|
|
|
use OCP\IRequest; |
31
|
|
|
|
32
|
|
|
class ProxyController extends Controller { |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var IClientService |
36
|
|
|
*/ |
37
|
|
|
protected $client; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param string $appName |
41
|
|
|
* @param IRequest $request an instance of the request |
42
|
|
|
* @param IClientService $client |
43
|
|
|
*/ |
44
|
|
|
public function __construct($appName, IRequest $request, |
45
|
|
|
IClientService $client) { |
46
|
|
|
parent::__construct($appName, $request); |
47
|
|
|
$this->client = $client; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @NoAdminRequired |
52
|
|
|
* |
53
|
|
|
* @param $url |
54
|
|
|
* @return StreamResponse|JSONResponse |
55
|
|
|
*/ |
56
|
|
|
public function proxy($url) { |
57
|
|
|
$client = $this->client->newClient(); |
58
|
|
|
try { |
59
|
|
|
$clientResponse = $client->get($url, [ |
60
|
|
|
'stream' => true, |
61
|
|
|
]); |
62
|
|
|
$response = new StreamResponse($clientResponse->getBody()); |
63
|
|
|
$response->setHeaders([ |
64
|
|
|
'Content-Type' => 'text/calendar', |
65
|
|
|
]); |
66
|
|
|
} catch (ClientException $e) { |
|
|
|
|
67
|
|
|
$error_code = $e->getResponse()->getStatusCode(); |
68
|
|
|
$response = new JSONResponse(); |
69
|
|
|
$response->setStatus($error_code); |
70
|
|
|
} |
71
|
|
|
return $response; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.