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