Passed
Push — master ( 16b801...e55e42 )
by Morris
11:05
created
lib/private/Http/Client/ClientService.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -35,25 +35,25 @@
 block discarded – undo
35 35
  * @package OC\Http
36 36
  */
37 37
 class ClientService implements IClientService {
38
-	/** @var IConfig */
39
-	private $config;
40
-	/** @var ICertificateManager */
41
-	private $certificateManager;
38
+    /** @var IConfig */
39
+    private $config;
40
+    /** @var ICertificateManager */
41
+    private $certificateManager;
42 42
 
43
-	/**
44
-	 * @param IConfig $config
45
-	 * @param ICertificateManager $certificateManager
46
-	 */
47
-	public function __construct(IConfig $config,
48
-								ICertificateManager $certificateManager) {
49
-		$this->config = $config;
50
-		$this->certificateManager = $certificateManager;
51
-	}
43
+    /**
44
+     * @param IConfig $config
45
+     * @param ICertificateManager $certificateManager
46
+     */
47
+    public function __construct(IConfig $config,
48
+                                ICertificateManager $certificateManager) {
49
+        $this->config = $config;
50
+        $this->certificateManager = $certificateManager;
51
+    }
52 52
 
53
-	/**
54
-	 * @return Client
55
-	 */
56
-	public function newClient(): IClient {
57
-		return new Client($this->config, $this->certificateManager, new GuzzleClient());
58
-	}
53
+    /**
54
+     * @return Client
55
+     */
56
+    public function newClient(): IClient {
57
+        return new Client($this->config, $this->certificateManager, new GuzzleClient());
58
+    }
59 59
 }
Please login to merge, or discard this patch.
lib/private/Http/Client/Client.php 2 patches
Indentation   +257 added lines, -257 removed lines patch added patch discarded remove patch
@@ -37,280 +37,280 @@
 block discarded – undo
37 37
  * @package OC\Http
38 38
  */
39 39
 class Client implements IClient {
40
-	/** @var GuzzleClient */
41
-	private $client;
42
-	/** @var IConfig */
43
-	private $config;
44
-	/** @var ICertificateManager */
45
-	private $certificateManager;
40
+    /** @var GuzzleClient */
41
+    private $client;
42
+    /** @var IConfig */
43
+    private $config;
44
+    /** @var ICertificateManager */
45
+    private $certificateManager;
46 46
 
47
-	/**
48
-	 * @param IConfig $config
49
-	 * @param ICertificateManager $certificateManager
50
-	 * @param GuzzleClient $client
51
-	 */
52
-	public function __construct(
53
-		IConfig $config,
54
-		ICertificateManager $certificateManager,
55
-		GuzzleClient $client
56
-	) {
57
-		$this->config = $config;
58
-		$this->client = $client;
59
-		$this->certificateManager = $certificateManager;
60
-	}
47
+    /**
48
+     * @param IConfig $config
49
+     * @param ICertificateManager $certificateManager
50
+     * @param GuzzleClient $client
51
+     */
52
+    public function __construct(
53
+        IConfig $config,
54
+        ICertificateManager $certificateManager,
55
+        GuzzleClient $client
56
+    ) {
57
+        $this->config = $config;
58
+        $this->client = $client;
59
+        $this->certificateManager = $certificateManager;
60
+    }
61 61
 
62
-	private function buildRequestOptions(array $options): array {
63
-		$defaults = [
64
-			RequestOptions::PROXY => $this->getProxyUri(),
65
-			RequestOptions::VERIFY => $this->getCertBundle(),
66
-		];
62
+    private function buildRequestOptions(array $options): array {
63
+        $defaults = [
64
+            RequestOptions::PROXY => $this->getProxyUri(),
65
+            RequestOptions::VERIFY => $this->getCertBundle(),
66
+        ];
67 67
 
68
-		$options = array_merge($defaults, $options);
68
+        $options = array_merge($defaults, $options);
69 69
 
70
-		if (!isset($options[RequestOptions::HEADERS]['User-Agent'])) {
71
-			$options[RequestOptions::HEADERS]['User-Agent'] = 'Nextcloud Server Crawler';
72
-		}
70
+        if (!isset($options[RequestOptions::HEADERS]['User-Agent'])) {
71
+            $options[RequestOptions::HEADERS]['User-Agent'] = 'Nextcloud Server Crawler';
72
+        }
73 73
 
74
-		return $options;
75
-	}
74
+        return $options;
75
+    }
76 76
 
77
-	private function getCertBundle(): string {
78
-		if ($this->certificateManager->listCertificates() !== []) {
79
-			return $this->certificateManager->getAbsoluteBundlePath();
80
-		}
77
+    private function getCertBundle(): string {
78
+        if ($this->certificateManager->listCertificates() !== []) {
79
+            return $this->certificateManager->getAbsoluteBundlePath();
80
+        }
81 81
 
82
-		// If the instance is not yet setup we need to use the static path as
83
-		// $this->certificateManager->getAbsoluteBundlePath() tries to instantiiate
84
-		// a view
85
-		if ($this->config->getSystemValue('installed', false)) {
86
-			return $this->certificateManager->getAbsoluteBundlePath(null);
87
-		}
82
+        // If the instance is not yet setup we need to use the static path as
83
+        // $this->certificateManager->getAbsoluteBundlePath() tries to instantiiate
84
+        // a view
85
+        if ($this->config->getSystemValue('installed', false)) {
86
+            return $this->certificateManager->getAbsoluteBundlePath(null);
87
+        }
88 88
 
89
-		return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
90
-	}
89
+        return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
90
+    }
91 91
 
92
-	/**
93
-	 * Get the proxy URI
94
-	 *
95
-	 * @return string|null
96
-	 */
97
-	private function getProxyUri(): ?string {
98
-		$proxyHost = $this->config->getSystemValue('proxy', null);
92
+    /**
93
+     * Get the proxy URI
94
+     *
95
+     * @return string|null
96
+     */
97
+    private function getProxyUri(): ?string {
98
+        $proxyHost = $this->config->getSystemValue('proxy', null);
99 99
 
100
-		if ($proxyHost === null) {
101
-			return null;
102
-		}
100
+        if ($proxyHost === null) {
101
+            return null;
102
+        }
103 103
 
104
-		$proxyUserPwd = $this->config->getSystemValue('proxyuserpwd', null);
104
+        $proxyUserPwd = $this->config->getSystemValue('proxyuserpwd', null);
105 105
 
106
-		if ($proxyUserPwd === null) {
107
-			return $proxyHost;
108
-		}
106
+        if ($proxyUserPwd === null) {
107
+            return $proxyHost;
108
+        }
109 109
 
110
-		return $proxyUserPwd . '@' . $proxyHost;
111
-	}
110
+        return $proxyUserPwd . '@' . $proxyHost;
111
+    }
112 112
 
113
-	/**
114
-	 * Sends a GET request
115
-	 *
116
-	 * @param string $uri
117
-	 * @param array $options Array such as
118
-	 *              'query' => [
119
-	 *                  'field' => 'abc',
120
-	 *                  'other_field' => '123',
121
-	 *                  'file_name' => fopen('/path/to/file', 'r'),
122
-	 *              ],
123
-	 *              'headers' => [
124
-	 *                  'foo' => 'bar',
125
-	 *              ],
126
-	 *              'cookies' => ['
127
-	 *                  'foo' => 'bar',
128
-	 *              ],
129
-	 *              'allow_redirects' => [
130
-	 *                   'max'       => 10,  // allow at most 10 redirects.
131
-	 *                   'strict'    => true,     // use "strict" RFC compliant redirects.
132
-	 *                   'referer'   => true,     // add a Referer header
133
-	 *                   'protocols' => ['https'] // only allow https URLs
134
-	 *              ],
135
-	 *              'save_to' => '/path/to/file', // save to a file or a stream
136
-	 *              'verify' => true, // bool or string to CA file
137
-	 *              'debug' => true,
138
-	 *              'timeout' => 5,
139
-	 * @return IResponse
140
-	 * @throws \Exception If the request could not get completed
141
-	 */
142
-	public function get(string $uri, array $options = []): IResponse {
143
-		$response = $this->client->request('get', $uri, $this->buildRequestOptions($options));
144
-		$isStream = isset($options['stream']) && $options['stream'];
145
-		return new Response($response, $isStream);
146
-	}
113
+    /**
114
+     * Sends a GET request
115
+     *
116
+     * @param string $uri
117
+     * @param array $options Array such as
118
+     *              'query' => [
119
+     *                  'field' => 'abc',
120
+     *                  'other_field' => '123',
121
+     *                  'file_name' => fopen('/path/to/file', 'r'),
122
+     *              ],
123
+     *              'headers' => [
124
+     *                  'foo' => 'bar',
125
+     *              ],
126
+     *              'cookies' => ['
127
+     *                  'foo' => 'bar',
128
+     *              ],
129
+     *              'allow_redirects' => [
130
+     *                   'max'       => 10,  // allow at most 10 redirects.
131
+     *                   'strict'    => true,     // use "strict" RFC compliant redirects.
132
+     *                   'referer'   => true,     // add a Referer header
133
+     *                   'protocols' => ['https'] // only allow https URLs
134
+     *              ],
135
+     *              'save_to' => '/path/to/file', // save to a file or a stream
136
+     *              'verify' => true, // bool or string to CA file
137
+     *              'debug' => true,
138
+     *              'timeout' => 5,
139
+     * @return IResponse
140
+     * @throws \Exception If the request could not get completed
141
+     */
142
+    public function get(string $uri, array $options = []): IResponse {
143
+        $response = $this->client->request('get', $uri, $this->buildRequestOptions($options));
144
+        $isStream = isset($options['stream']) && $options['stream'];
145
+        return new Response($response, $isStream);
146
+    }
147 147
 
148
-	/**
149
-	 * Sends a HEAD request
150
-	 *
151
-	 * @param string $uri
152
-	 * @param array $options Array such as
153
-	 *              'headers' => [
154
-	 *                  'foo' => 'bar',
155
-	 *              ],
156
-	 *              'cookies' => ['
157
-	 *                  'foo' => 'bar',
158
-	 *              ],
159
-	 *              'allow_redirects' => [
160
-	 *                   'max'       => 10,  // allow at most 10 redirects.
161
-	 *                   'strict'    => true,     // use "strict" RFC compliant redirects.
162
-	 *                   'referer'   => true,     // add a Referer header
163
-	 *                   'protocols' => ['https'] // only allow https URLs
164
-	 *              ],
165
-	 *              'save_to' => '/path/to/file', // save to a file or a stream
166
-	 *              'verify' => true, // bool or string to CA file
167
-	 *              'debug' => true,
168
-	 *              'timeout' => 5,
169
-	 * @return IResponse
170
-	 * @throws \Exception If the request could not get completed
171
-	 */
172
-	public function head(string $uri, array $options = []): IResponse {
173
-		$response = $this->client->request('head', $uri, $this->buildRequestOptions($options));
174
-		return new Response($response);
175
-	}
148
+    /**
149
+     * Sends a HEAD request
150
+     *
151
+     * @param string $uri
152
+     * @param array $options Array such as
153
+     *              'headers' => [
154
+     *                  'foo' => 'bar',
155
+     *              ],
156
+     *              'cookies' => ['
157
+     *                  'foo' => 'bar',
158
+     *              ],
159
+     *              'allow_redirects' => [
160
+     *                   'max'       => 10,  // allow at most 10 redirects.
161
+     *                   'strict'    => true,     // use "strict" RFC compliant redirects.
162
+     *                   'referer'   => true,     // add a Referer header
163
+     *                   'protocols' => ['https'] // only allow https URLs
164
+     *              ],
165
+     *              'save_to' => '/path/to/file', // save to a file or a stream
166
+     *              'verify' => true, // bool or string to CA file
167
+     *              'debug' => true,
168
+     *              'timeout' => 5,
169
+     * @return IResponse
170
+     * @throws \Exception If the request could not get completed
171
+     */
172
+    public function head(string $uri, array $options = []): IResponse {
173
+        $response = $this->client->request('head', $uri, $this->buildRequestOptions($options));
174
+        return new Response($response);
175
+    }
176 176
 
177
-	/**
178
-	 * Sends a POST request
179
-	 *
180
-	 * @param string $uri
181
-	 * @param array $options Array such as
182
-	 *              'body' => [
183
-	 *                  'field' => 'abc',
184
-	 *                  'other_field' => '123',
185
-	 *                  'file_name' => fopen('/path/to/file', 'r'),
186
-	 *              ],
187
-	 *              'headers' => [
188
-	 *                  'foo' => 'bar',
189
-	 *              ],
190
-	 *              'cookies' => ['
191
-	 *                  'foo' => 'bar',
192
-	 *              ],
193
-	 *              'allow_redirects' => [
194
-	 *                   'max'       => 10,  // allow at most 10 redirects.
195
-	 *                   'strict'    => true,     // use "strict" RFC compliant redirects.
196
-	 *                   'referer'   => true,     // add a Referer header
197
-	 *                   'protocols' => ['https'] // only allow https URLs
198
-	 *              ],
199
-	 *              'save_to' => '/path/to/file', // save to a file or a stream
200
-	 *              'verify' => true, // bool or string to CA file
201
-	 *              'debug' => true,
202
-	 *              'timeout' => 5,
203
-	 * @return IResponse
204
-	 * @throws \Exception If the request could not get completed
205
-	 */
206
-	public function post(string $uri, array $options = []): IResponse {
207
-		if (isset($options['body']) && is_array($options['body'])) {
208
-			$options['form_params'] = $options['body'];
209
-			unset($options['body']);
210
-		}
211
-		$response = $this->client->request('post', $uri, $this->buildRequestOptions($options));
212
-		return new Response($response);
213
-	}
177
+    /**
178
+     * Sends a POST request
179
+     *
180
+     * @param string $uri
181
+     * @param array $options Array such as
182
+     *              'body' => [
183
+     *                  'field' => 'abc',
184
+     *                  'other_field' => '123',
185
+     *                  'file_name' => fopen('/path/to/file', 'r'),
186
+     *              ],
187
+     *              'headers' => [
188
+     *                  'foo' => 'bar',
189
+     *              ],
190
+     *              'cookies' => ['
191
+     *                  'foo' => 'bar',
192
+     *              ],
193
+     *              'allow_redirects' => [
194
+     *                   'max'       => 10,  // allow at most 10 redirects.
195
+     *                   'strict'    => true,     // use "strict" RFC compliant redirects.
196
+     *                   'referer'   => true,     // add a Referer header
197
+     *                   'protocols' => ['https'] // only allow https URLs
198
+     *              ],
199
+     *              'save_to' => '/path/to/file', // save to a file or a stream
200
+     *              'verify' => true, // bool or string to CA file
201
+     *              'debug' => true,
202
+     *              'timeout' => 5,
203
+     * @return IResponse
204
+     * @throws \Exception If the request could not get completed
205
+     */
206
+    public function post(string $uri, array $options = []): IResponse {
207
+        if (isset($options['body']) && is_array($options['body'])) {
208
+            $options['form_params'] = $options['body'];
209
+            unset($options['body']);
210
+        }
211
+        $response = $this->client->request('post', $uri, $this->buildRequestOptions($options));
212
+        return new Response($response);
213
+    }
214 214
 
215
-	/**
216
-	 * Sends a PUT request
217
-	 *
218
-	 * @param string $uri
219
-	 * @param array $options Array such as
220
-	 *              'body' => [
221
-	 *                  'field' => 'abc',
222
-	 *                  'other_field' => '123',
223
-	 *                  'file_name' => fopen('/path/to/file', 'r'),
224
-	 *              ],
225
-	 *              'headers' => [
226
-	 *                  'foo' => 'bar',
227
-	 *              ],
228
-	 *              'cookies' => ['
229
-	 *                  'foo' => 'bar',
230
-	 *              ],
231
-	 *              'allow_redirects' => [
232
-	 *                   'max'       => 10,  // allow at most 10 redirects.
233
-	 *                   'strict'    => true,     // use "strict" RFC compliant redirects.
234
-	 *                   'referer'   => true,     // add a Referer header
235
-	 *                   'protocols' => ['https'] // only allow https URLs
236
-	 *              ],
237
-	 *              'save_to' => '/path/to/file', // save to a file or a stream
238
-	 *              'verify' => true, // bool or string to CA file
239
-	 *              'debug' => true,
240
-	 *              'timeout' => 5,
241
-	 * @return IResponse
242
-	 * @throws \Exception If the request could not get completed
243
-	 */
244
-	public function put(string $uri, array $options = []): IResponse {
245
-		$response = $this->client->request('put', $uri, $this->buildRequestOptions($options));
246
-		return new Response($response);
247
-	}
215
+    /**
216
+     * Sends a PUT request
217
+     *
218
+     * @param string $uri
219
+     * @param array $options Array such as
220
+     *              'body' => [
221
+     *                  'field' => 'abc',
222
+     *                  'other_field' => '123',
223
+     *                  'file_name' => fopen('/path/to/file', 'r'),
224
+     *              ],
225
+     *              'headers' => [
226
+     *                  'foo' => 'bar',
227
+     *              ],
228
+     *              'cookies' => ['
229
+     *                  'foo' => 'bar',
230
+     *              ],
231
+     *              'allow_redirects' => [
232
+     *                   'max'       => 10,  // allow at most 10 redirects.
233
+     *                   'strict'    => true,     // use "strict" RFC compliant redirects.
234
+     *                   'referer'   => true,     // add a Referer header
235
+     *                   'protocols' => ['https'] // only allow https URLs
236
+     *              ],
237
+     *              'save_to' => '/path/to/file', // save to a file or a stream
238
+     *              'verify' => true, // bool or string to CA file
239
+     *              'debug' => true,
240
+     *              'timeout' => 5,
241
+     * @return IResponse
242
+     * @throws \Exception If the request could not get completed
243
+     */
244
+    public function put(string $uri, array $options = []): IResponse {
245
+        $response = $this->client->request('put', $uri, $this->buildRequestOptions($options));
246
+        return new Response($response);
247
+    }
248 248
 
249
-	/**
250
-	 * Sends a DELETE request
251
-	 *
252
-	 * @param string $uri
253
-	 * @param array $options Array such as
254
-	 *              'body' => [
255
-	 *                  'field' => 'abc',
256
-	 *                  'other_field' => '123',
257
-	 *                  'file_name' => fopen('/path/to/file', 'r'),
258
-	 *              ],
259
-	 *              'headers' => [
260
-	 *                  'foo' => 'bar',
261
-	 *              ],
262
-	 *              'cookies' => ['
263
-	 *                  'foo' => 'bar',
264
-	 *              ],
265
-	 *              'allow_redirects' => [
266
-	 *                   'max'       => 10,  // allow at most 10 redirects.
267
-	 *                   'strict'    => true,     // use "strict" RFC compliant redirects.
268
-	 *                   'referer'   => true,     // add a Referer header
269
-	 *                   'protocols' => ['https'] // only allow https URLs
270
-	 *              ],
271
-	 *              'save_to' => '/path/to/file', // save to a file or a stream
272
-	 *              'verify' => true, // bool or string to CA file
273
-	 *              'debug' => true,
274
-	 *              'timeout' => 5,
275
-	 * @return IResponse
276
-	 * @throws \Exception If the request could not get completed
277
-	 */
278
-	public function delete(string $uri, array $options = []): IResponse {
279
-		$response = $this->client->request('delete', $uri, $this->buildRequestOptions($options));
280
-		return new Response($response);
281
-	}
249
+    /**
250
+     * Sends a DELETE request
251
+     *
252
+     * @param string $uri
253
+     * @param array $options Array such as
254
+     *              'body' => [
255
+     *                  'field' => 'abc',
256
+     *                  'other_field' => '123',
257
+     *                  'file_name' => fopen('/path/to/file', 'r'),
258
+     *              ],
259
+     *              'headers' => [
260
+     *                  'foo' => 'bar',
261
+     *              ],
262
+     *              'cookies' => ['
263
+     *                  'foo' => 'bar',
264
+     *              ],
265
+     *              'allow_redirects' => [
266
+     *                   'max'       => 10,  // allow at most 10 redirects.
267
+     *                   'strict'    => true,     // use "strict" RFC compliant redirects.
268
+     *                   'referer'   => true,     // add a Referer header
269
+     *                   'protocols' => ['https'] // only allow https URLs
270
+     *              ],
271
+     *              'save_to' => '/path/to/file', // save to a file or a stream
272
+     *              'verify' => true, // bool or string to CA file
273
+     *              'debug' => true,
274
+     *              'timeout' => 5,
275
+     * @return IResponse
276
+     * @throws \Exception If the request could not get completed
277
+     */
278
+    public function delete(string $uri, array $options = []): IResponse {
279
+        $response = $this->client->request('delete', $uri, $this->buildRequestOptions($options));
280
+        return new Response($response);
281
+    }
282 282
 
283
-	/**
284
-	 * Sends a options request
285
-	 *
286
-	 * @param string $uri
287
-	 * @param array $options Array such as
288
-	 *              'body' => [
289
-	 *                  'field' => 'abc',
290
-	 *                  'other_field' => '123',
291
-	 *                  'file_name' => fopen('/path/to/file', 'r'),
292
-	 *              ],
293
-	 *              'headers' => [
294
-	 *                  'foo' => 'bar',
295
-	 *              ],
296
-	 *              'cookies' => ['
297
-	 *                  'foo' => 'bar',
298
-	 *              ],
299
-	 *              'allow_redirects' => [
300
-	 *                   'max'       => 10,  // allow at most 10 redirects.
301
-	 *                   'strict'    => true,     // use "strict" RFC compliant redirects.
302
-	 *                   'referer'   => true,     // add a Referer header
303
-	 *                   'protocols' => ['https'] // only allow https URLs
304
-	 *              ],
305
-	 *              'save_to' => '/path/to/file', // save to a file or a stream
306
-	 *              'verify' => true, // bool or string to CA file
307
-	 *              'debug' => true,
308
-	 *              'timeout' => 5,
309
-	 * @return IResponse
310
-	 * @throws \Exception If the request could not get completed
311
-	 */
312
-	public function options(string $uri, array $options = []): IResponse {
313
-		$response = $this->client->request('options', $uri, $this->buildRequestOptions($options));
314
-		return new Response($response);
315
-	}
283
+    /**
284
+     * Sends a options request
285
+     *
286
+     * @param string $uri
287
+     * @param array $options Array such as
288
+     *              'body' => [
289
+     *                  'field' => 'abc',
290
+     *                  'other_field' => '123',
291
+     *                  'file_name' => fopen('/path/to/file', 'r'),
292
+     *              ],
293
+     *              'headers' => [
294
+     *                  'foo' => 'bar',
295
+     *              ],
296
+     *              'cookies' => ['
297
+     *                  'foo' => 'bar',
298
+     *              ],
299
+     *              'allow_redirects' => [
300
+     *                   'max'       => 10,  // allow at most 10 redirects.
301
+     *                   'strict'    => true,     // use "strict" RFC compliant redirects.
302
+     *                   'referer'   => true,     // add a Referer header
303
+     *                   'protocols' => ['https'] // only allow https URLs
304
+     *              ],
305
+     *              'save_to' => '/path/to/file', // save to a file or a stream
306
+     *              'verify' => true, // bool or string to CA file
307
+     *              'debug' => true,
308
+     *              'timeout' => 5,
309
+     * @return IResponse
310
+     * @throws \Exception If the request could not get completed
311
+     */
312
+    public function options(string $uri, array $options = []): IResponse {
313
+        $response = $this->client->request('options', $uri, $this->buildRequestOptions($options));
314
+        return new Response($response);
315
+    }
316 316
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 			return $this->certificateManager->getAbsoluteBundlePath(null);
87 87
 		}
88 88
 
89
-		return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
89
+		return \OC::$SERVERROOT.'/resources/config/ca-bundle.crt';
90 90
 	}
91 91
 
92 92
 	/**
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 			return $proxyHost;
108 108
 		}
109 109
 
110
-		return $proxyUserPwd . '@' . $proxyHost;
110
+		return $proxyUserPwd.'@'.$proxyHost;
111 111
 	}
112 112
 
113 113
 	/**
Please login to merge, or discard this patch.