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