Completed
Push — master ( 24e24a...fca7db )
by mains
02:44
created
php/Requests/libary/Requests/Transport/fsockopen.php 1 patch
Braces   +142 added lines, -71 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@  discard block
 block discarded – undo
12 12
  * @package Requests
13 13
  * @subpackage Transport
14 14
  */
15
-class Requests_Transport_fsockopen implements Requests_Transport {
15
+class Requests_Transport_fsockopen implements Requests_Transport
16
+{
16 17
 	/**
17 18
 	 * Second to microsecond conversion
18 19
 	 *
@@ -55,11 +56,13 @@  discard block
 block discarded – undo
55 56
 	 * @param array $options Request options, see {@see Requests::response()} for documentation
56 57
 	 * @return string Raw HTTP result
57 58
 	 */
58
-	public function request($url, $headers = array(), $data = array(), $options = array()) {
59
+	public function request($url, $headers = array(), $data = array(), $options = array())
60
+	{
59 61
 		$options['hooks']->dispatch('fsockopen.before_request');
60 62
 
61 63
 		$url_parts = parse_url($url);
62
-		if (empty($url_parts)) {
64
+		if (empty($url_parts))
65
+		{
63 66
 			throw new Requests_Exception('Invalid URL.', 'invalidurl', $url);
64 67
 		}
65 68
 		$host = $url_parts['host'];
@@ -68,9 +71,11 @@  discard block
 block discarded – undo
68 71
 		$case_insensitive_headers = new Requests_Utility_CaseInsensitiveDictionary($headers);
69 72
 
70 73
 		// HTTPS support
71
-		if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') {
74
+		if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https')
75
+		{
72 76
 			$remote_socket = 'ssl://' . $host;
73
-			if (!isset($url_parts['port'])) {
77
+			if (!isset($url_parts['port']))
78
+			{
74 79
 				$url_parts['port'] = 443;
75 80
 			}
76 81
 
@@ -82,36 +87,44 @@  discard block
 block discarded – undo
82 87
 			$verifyname = true;
83 88
 
84 89
 			// SNI, if enabled (OpenSSL >=0.9.8j)
85
-			if (defined('OPENSSL_TLSEXT_SERVER_NAME') && OPENSSL_TLSEXT_SERVER_NAME) {
90
+			if (defined('OPENSSL_TLSEXT_SERVER_NAME') && OPENSSL_TLSEXT_SERVER_NAME)
91
+			{
86 92
 				$context_options['SNI_enabled'] = true;
87
-				if (isset($options['verifyname']) && $options['verifyname'] === false) {
93
+				if (isset($options['verifyname']) && $options['verifyname'] === false)
94
+				{
88 95
 					$context_options['SNI_enabled'] = false;
89 96
 				}
90 97
 			}
91 98
 
92
-			if (isset($options['verify'])) {
93
-				if ($options['verify'] === false) {
99
+			if (isset($options['verify']))
100
+			{
101
+				if ($options['verify'] === false)
102
+				{
94 103
 					$context_options['verify_peer'] = false;
95 104
 				}
96
-				elseif (is_string($options['verify'])) {
105
+				elseif (is_string($options['verify']))
106
+				{
97 107
 					$context_options['cafile'] = $options['verify'];
98 108
 				}
99 109
 			}
100 110
 
101
-			if (isset($options['verifyname']) && $options['verifyname'] === false) {
111
+			if (isset($options['verifyname']) && $options['verifyname'] === false)
112
+			{
102 113
 				$context_options['verify_peer_name'] = false;
103 114
 				$verifyname = false;
104 115
 			}
105 116
 
106 117
 			stream_context_set_option($context, array('ssl' => $context_options));
107 118
 		}
108
-		else {
119
+		else
120
+		{
109 121
 			$remote_socket = 'tcp://' . $host;
110 122
 		}
111 123
 
112 124
 		$this->max_bytes = $options['max_bytes'];
113 125
 
114
-		if (!isset($url_parts['port'])) {
126
+		if (!isset($url_parts['port']))
127
+		{
115 128
 			$url_parts['port'] = 80;
116 129
 		}
117 130
 		$remote_socket .= ':' . $url_parts['port'];
@@ -124,12 +137,15 @@  discard block
 block discarded – undo
124 137
 
125 138
 		restore_error_handler();
126 139
 
127
-		if ($verifyname && !$this->verify_certificate_from_context($host, $context)) {
140
+		if ($verifyname && !$this->verify_certificate_from_context($host, $context))
141
+		{
128 142
 			throw new Requests_Exception('SSL certificate did not match the requested domain name', 'ssl.no_match');
129 143
 		}
130 144
 
131
-		if (!$socket) {
132
-			if ($errno === 0) {
145
+		if (!$socket)
146
+		{
147
+			if ($errno === 0)
148
+			{
133 149
 				// Connection issue
134 150
 				throw new Requests_Exception(rtrim($this->connect_error), 'fsockopen.connect_error');
135 151
 			}
@@ -139,11 +155,13 @@  discard block
 block discarded – undo
139 155
 
140 156
 		$data_format = $options['data_format'];
141 157
 
142
-		if ($data_format === 'query') {
158
+		if ($data_format === 'query')
159
+		{
143 160
 			$path = self::format_get($url_parts, $data);
144 161
 			$data = '';
145 162
 		}
146
-		else {
163
+		else
164
+		{
147 165
 			$path = self::format_get($url_parts, array());
148 166
 		}
149 167
 
@@ -152,56 +170,69 @@  discard block
 block discarded – undo
152 170
 		$request_body = '';
153 171
 		$out = sprintf("%s %s HTTP/%.1f\r\n", $options['type'], $path, $options['protocol_version']);
154 172
 
155
-		if ($options['type'] !== Requests::TRACE) {
156
-			if (is_array($data)) {
173
+		if ($options['type'] !== Requests::TRACE)
174
+		{
175
+			if (is_array($data))
176
+			{
157 177
 				$request_body = http_build_query($data, null, '&');
158 178
 			}
159
-			else {
179
+			else
180
+			{
160 181
 				$request_body = $data;
161 182
 			}
162 183
 
163
-			if (!empty($data)) {
164
-				if (!isset($case_insensitive_headers['Content-Length'])) {
184
+			if (!empty($data))
185
+			{
186
+				if (!isset($case_insensitive_headers['Content-Length']))
187
+				{
165 188
 					$headers['Content-Length'] = strlen($request_body);
166 189
 				}
167 190
 
168
-				if (!isset($case_insensitive_headers['Content-Type'])) {
191
+				if (!isset($case_insensitive_headers['Content-Type']))
192
+				{
169 193
 					$headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
170 194
 				}
171 195
 			}
172 196
 		}
173 197
 
174
-		if (!isset($case_insensitive_headers['Host'])) {
198
+		if (!isset($case_insensitive_headers['Host']))
199
+		{
175 200
 			$out .= sprintf('Host: %s', $url_parts['host']);
176 201
 
177
-			if (( 'http' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 80 ) || ( 'https' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 443 )) {
202
+			if (( 'http' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 80 ) || ( 'https' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 443 ))
203
+			{
178 204
 				$out .= ':' . $url_parts['port'];
179 205
 			}
180 206
 			$out .= "\r\n";
181 207
 		}
182 208
 
183
-		if (!isset($case_insensitive_headers['User-Agent'])) {
209
+		if (!isset($case_insensitive_headers['User-Agent']))
210
+		{
184 211
 			$out .= sprintf("User-Agent: %s\r\n", $options['useragent']);
185 212
 		}
186 213
 
187 214
 		$accept_encoding = $this->accept_encoding();
188
-		if (!isset($case_insensitive_headers['Accept-Encoding']) && !empty($accept_encoding)) {
215
+		if (!isset($case_insensitive_headers['Accept-Encoding']) && !empty($accept_encoding))
216
+		{
189 217
 			$out .= sprintf("Accept-Encoding: %s\r\n", $accept_encoding);
190 218
 		}
191 219
 
192 220
 		$headers = Requests::flatten($headers);
193 221
 
194
-		if (!empty($headers)) {
222
+		if (!empty($headers))
223
+		{
195 224
 			$out .= implode($headers, "\r\n") . "\r\n";
196 225
 		}
197 226
 
198 227
 		$options['hooks']->dispatch('fsockopen.after_headers', array(&$out));
199 228
 
200
-		if (substr($out, -2) !== "\r\n") {
229
+		if (substr($out, -2) !== "\r\n")
230
+		{
201 231
 			$out .= "\r\n";
202 232
 		}
203 233
 
204
-		if (!isset($case_insensitive_headers['Connection'])) {
234
+		if (!isset($case_insensitive_headers['Connection']))
235
+		{
205 236
 			$out .= "Connection: Close\r\n";
206 237
 		}
207 238
 
@@ -212,7 +243,8 @@  discard block
 block discarded – undo
212 243
 		fwrite($socket, $out);
213 244
 		$options['hooks']->dispatch('fsockopen.after_send', array($out));
214 245
 
215
-		if (!$options['blocking']) {
246
+		if (!$options['blocking'])
247
+		{
216 248
 			fclose($socket);
217 249
 			$fake_headers = '';
218 250
 			$options['hooks']->dispatch('fsockopen.after_request', array(&$fake_headers));
@@ -220,10 +252,12 @@  discard block
 block discarded – undo
220 252
 		}
221 253
 
222 254
 		$timeout_sec = (int) floor($options['timeout']);
223
-		if ($timeout_sec == $options['timeout']) {
255
+		if ($timeout_sec == $options['timeout'])
256
+		{
224 257
 			$timeout_msec = 0;
225 258
 		}
226
-		else {
259
+		else
260
+		{
227 261
 			$timeout_msec = self::SECOND_IN_MICROSECONDS * $options['timeout'] % self::SECOND_IN_MICROSECONDS;
228 262
 		}
229 263
 		stream_set_timeout($socket, $timeout_sec, $timeout_msec);
@@ -233,35 +267,44 @@  discard block
 block discarded – undo
233 267
 		$size = 0;
234 268
 		$doingbody = false;
235 269
 		$download = false;
236
-		if ($options['filename']) {
270
+		if ($options['filename'])
271
+		{
237 272
 			$download = fopen($options['filename'], 'wb');
238 273
 		}
239 274
 
240
-		while (!feof($socket)) {
275
+		while (!feof($socket))
276
+		{
241 277
 			$this->info = stream_get_meta_data($socket);
242
-			if ($this->info['timed_out']) {
278
+			if ($this->info['timed_out'])
279
+			{
243 280
 				throw new Requests_Exception('fsocket timed out', 'timeout');
244 281
 			}
245 282
 
246 283
 			$block = fread($socket, Requests::BUFFER_SIZE);
247
-			if (!$doingbody) {
284
+			if (!$doingbody)
285
+			{
248 286
 				$response .= $block;
249
-				if (strpos($response, "\r\n\r\n")) {
287
+				if (strpos($response, "\r\n\r\n"))
288
+				{
250 289
 					list($headers, $block) = explode("\r\n\r\n", $response, 2);
251 290
 					$doingbody = true;
252 291
 				}
253 292
 			}
254 293
 
255 294
 			// Are we in body mode now?
256
-			if ($doingbody) {
295
+			if ($doingbody)
296
+			{
257 297
 				$options['hooks']->dispatch('request.progress', array($block, $size, $this->max_bytes));
258 298
 				$data_length = strlen($block);
259
-				if ($this->max_bytes) {
299
+				if ($this->max_bytes)
300
+				{
260 301
 					// Have we already hit a limit?
261
-					if ($size === $this->max_bytes) {
302
+					if ($size === $this->max_bytes)
303
+					{
262 304
 						continue;
263 305
 					}
264
-					if (($size + $data_length) > $this->max_bytes) {
306
+					if (($size + $data_length) > $this->max_bytes)
307
+					{
265 308
 						// Limit the length
266 309
 						$limited_length = ($this->max_bytes - $size);
267 310
 						$block = substr($block, 0, $limited_length);
@@ -269,20 +312,24 @@  discard block
 block discarded – undo
269 312
 				}
270 313
 
271 314
 				$size += strlen($block);
272
-				if ($download) {
315
+				if ($download)
316
+				{
273 317
 					fwrite($download, $block);
274 318
 				}
275
-				else {
319
+				else
320
+				{
276 321
 					$body .= $block;
277 322
 				}
278 323
 			}
279 324
 		}
280 325
 		$this->headers = $headers;
281 326
 
282
-		if ($download) {
327
+		if ($download)
328
+		{
283 329
 			fclose($download);
284 330
 		}
285
-		else {
331
+		else
332
+		{
286 333
 			$this->headers .= "\r\n\r\n" . $body;
287 334
 		}
288 335
 		fclose($socket);
@@ -298,21 +345,26 @@  discard block
 block discarded – undo
298 345
 	 * @param array $options Global options, see {@see Requests::response()} for documentation
299 346
 	 * @return array Array of Requests_Response objects (may contain Requests_Exception or string responses as well)
300 347
 	 */
301
-	public function request_multiple($requests, $options) {
348
+	public function request_multiple($requests, $options)
349
+	{
302 350
 		$responses = array();
303 351
 		$class = get_class($this);
304
-		foreach ($requests as $id => $request) {
305
-			try {
352
+		foreach ($requests as $id => $request)
353
+		{
354
+			try
355
+			{
306 356
 				$handler = new $class();
307 357
 				$responses[$id] = $handler->request($request['url'], $request['headers'], $request['data'], $request['options']);
308 358
 
309 359
 				$request['options']['hooks']->dispatch('transport.internal.parse_response', array(&$responses[$id], $request));
310 360
 			}
311
-			catch (Requests_Exception $e) {
361
+			catch (Requests_Exception $e)
362
+			{
312 363
 				$responses[$id] = $e;
313 364
 			}
314 365
 
315
-			if (!is_string($responses[$id])) {
366
+			if (!is_string($responses[$id]))
367
+			{
316 368
 				$request['options']['hooks']->dispatch('multiple.request.complete', array(&$responses[$id], $id));
317 369
 			}
318 370
 		}
@@ -325,13 +377,16 @@  discard block
 block discarded – undo
325 377
 	 *
326 378
 	 * @return string Accept-Encoding header value
327 379
 	 */
328
-	protected static function accept_encoding() {
380
+	protected static function accept_encoding()
381
+	{
329 382
 		$type = array();
330
-		if (function_exists('gzinflate')) {
383
+		if (function_exists('gzinflate'))
384
+		{
331 385
 			$type[] = 'deflate;q=1.0';
332 386
 		}
333 387
 
334
-		if (function_exists('gzuncompress')) {
388
+		if (function_exists('gzuncompress'))
389
+		{
335 390
 			$type[] = 'compress;q=0.5';
336 391
 		}
337 392
 
@@ -347,24 +402,31 @@  discard block
 block discarded – undo
347 402
 	 * @param array|object $data Data to build query using, see {@see https://secure.php.net/http_build_query}
348 403
 	 * @return string URL with data
349 404
 	 */
350
-	protected static function format_get($url_parts, $data) {
351
-		if (!empty($data)) {
352
-			if (empty($url_parts['query'])) {
405
+	protected static function format_get($url_parts, $data)
406
+	{
407
+		if (!empty($data))
408
+		{
409
+			if (empty($url_parts['query']))
410
+			{
353 411
 				$url_parts['query'] = '';
354 412
 			}
355 413
 
356 414
 			$url_parts['query'] .= '&' . http_build_query($data, null, '&');
357 415
 			$url_parts['query'] = trim($url_parts['query'], '&');
358 416
 		}
359
-		if (isset($url_parts['path'])) {
360
-			if (isset($url_parts['query'])) {
417
+		if (isset($url_parts['path']))
418
+		{
419
+			if (isset($url_parts['query']))
420
+			{
361 421
 				$get = $url_parts['path'] . '?' . $url_parts['query'];
362 422
 			}
363
-			else {
423
+			else
424
+			{
364 425
 				$get = $url_parts['path'];
365 426
 			}
366 427
 		}
367
-		else {
428
+		else
429
+		{
368 430
 			$get = '/';
369 431
 		}
370 432
 		return $get;
@@ -376,9 +438,11 @@  discard block
 block discarded – undo
376 438
 	 * @param int $errno Error number (e.g. E_WARNING)
377 439
 	 * @param string $errstr Error message
378 440
 	 */
379
-	public function connect_error_handler($errno, $errstr) {
441
+	public function connect_error_handler($errno, $errstr)
442
+	{
380 443
 		// Double-check we can handle it
381
-		if (($errno & E_WARNING) === 0 && ($errno & E_NOTICE) === 0) {
444
+		if (($errno & E_WARNING) === 0 && ($errno & E_NOTICE) === 0)
445
+		{
382 446
 			// Return false to indicate the default error handler should engage
383 447
 			return false;
384 448
 		}
@@ -402,12 +466,14 @@  discard block
 block discarded – undo
402 466
 	 * @param resource $context Stream context
403 467
 	 * @return bool
404 468
 	 */
405
-	public function verify_certificate_from_context($host, $context) {
469
+	public function verify_certificate_from_context($host, $context)
470
+	{
406 471
 		$meta = stream_context_get_options($context);
407 472
 
408 473
 		// If we don't have SSL options, then we couldn't make the connection at
409 474
 		// all
410
-		if (empty($meta) || empty($meta['ssl']) || empty($meta['ssl']['peer_certificate'])) {
475
+		if (empty($meta) || empty($meta['ssl']) || empty($meta['ssl']['peer_certificate']))
476
+		{
411 477
 			throw new Requests_Exception(rtrim($this->connect_error), 'ssl.connect_error');
412 478
 		}
413 479
 
@@ -422,19 +488,24 @@  discard block
 block discarded – undo
422 488
 	 * @codeCoverageIgnore
423 489
 	 * @return boolean True if the transport is valid, false otherwise.
424 490
 	 */
425
-	public static function test($capabilities = array()) {
426
-		if (!function_exists('fsockopen')) {
491
+	public static function test($capabilities = array())
492
+	{
493
+		if (!function_exists('fsockopen'))
494
+		{
427 495
 			return false;
428 496
 		}
429 497
 
430 498
 		// If needed, check that streams support SSL
431
-		if (isset($capabilities['ssl']) && $capabilities['ssl']) {
432
-			if (!extension_loaded('openssl') || !function_exists('openssl_x509_parse')) {
499
+		if (isset($capabilities['ssl']) && $capabilities['ssl'])
500
+		{
501
+			if (!extension_loaded('openssl') || !function_exists('openssl_x509_parse'))
502
+			{
433 503
 				return false;
434 504
 			}
435 505
 
436 506
 			// Currently broken, thanks to https://github.com/facebook/hhvm/issues/2156
437
-			if (defined('HHVM_VERSION')) {
507
+			if (defined('HHVM_VERSION'))
508
+			{
438 509
 				return false;
439 510
 			}
440 511
 		}
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Session.php 1 patch
Braces   +50 added lines, -25 removed lines patch added patch discarded remove patch
@@ -17,7 +17,8 @@  discard block
 block discarded – undo
17 17
  * @package Requests
18 18
  * @subpackage Session Handler
19 19
  */
20
-class Requests_Session {
20
+class Requests_Session
21
+{
21 22
 	/**
22 23
 	 * Base URL for requests
23 24
 	 *
@@ -63,13 +64,15 @@  discard block
 block discarded – undo
63 64
 	 * @param array $data Default data for requests
64 65
 	 * @param array $options Default options for requests
65 66
 	 */
66
-	public function __construct($url = null, $headers = array(), $data = array(), $options = array()) {
67
+	public function __construct($url = null, $headers = array(), $data = array(), $options = array())
68
+	{
67 69
 		$this->url = $url;
68 70
 		$this->headers = $headers;
69 71
 		$this->data = $data;
70 72
 		$this->options = $options;
71 73
 
72
-		if (empty($this->options['cookies'])) {
74
+		if (empty($this->options['cookies']))
75
+		{
73 76
 			$this->options['cookies'] = new Requests_Cookie_Jar();
74 77
 		}
75 78
 	}
@@ -80,8 +83,10 @@  discard block
 block discarded – undo
80 83
 	 * @param string $key Property key
81 84
 	 * @return mixed|null Property value, null if none found
82 85
 	 */
83
-	public function __get($key) {
84
-		if (isset($this->options[$key])) {
86
+	public function __get($key)
87
+	{
88
+		if (isset($this->options[$key]))
89
+		{
85 90
 			return $this->options[$key];
86 91
 		}
87 92
 
@@ -94,7 +99,8 @@  discard block
 block discarded – undo
94 99
 	 * @param string $key Property key
95 100
 	 * @param mixed $value Property value
96 101
 	 */
97
-	public function __set($key, $value) {
102
+	public function __set($key, $value)
103
+	{
98 104
 		$this->options[$key] = $value;
99 105
 	}
100 106
 
@@ -103,7 +109,8 @@  discard block
 block discarded – undo
103 109
 	 *
104 110
 	 * @param string $key Property key
105 111
 	 */
106
-	public function __isset($key) {
112
+	public function __isset($key)
113
+	{
107 114
 		return isset($this->options[$key]);
108 115
 	}
109 116
 
@@ -112,8 +119,10 @@  discard block
 block discarded – undo
112 119
 	 *
113 120
 	 * @param string $key Property key
114 121
 	 */
115
-	public function __unset($key) {
116
-		if (isset($this->options[$key])) {
122
+	public function __unset($key)
123
+	{
124
+		if (isset($this->options[$key]))
125
+		{
117 126
 			unset($this->options[$key]);
118 127
 		}
119 128
 	}
@@ -128,21 +137,24 @@  discard block
 block discarded – undo
128 137
 	/**
129 138
 	 * Send a GET request
130 139
 	 */
131
-	public function get($url, $headers = array(), $options = array()) {
140
+	public function get($url, $headers = array(), $options = array())
141
+	{
132 142
 		return $this->request($url, $headers, null, Requests::GET, $options);
133 143
 	}
134 144
 
135 145
 	/**
136 146
 	 * Send a HEAD request
137 147
 	 */
138
-	public function head($url, $headers = array(), $options = array()) {
148
+	public function head($url, $headers = array(), $options = array())
149
+	{
139 150
 		return $this->request($url, $headers, null, Requests::HEAD, $options);
140 151
 	}
141 152
 
142 153
 	/**
143 154
 	 * Send a DELETE request
144 155
 	 */
145
-	public function delete($url, $headers = array(), $options = array()) {
156
+	public function delete($url, $headers = array(), $options = array())
157
+	{
146 158
 		return $this->request($url, $headers, null, Requests::DELETE, $options);
147 159
 	}
148 160
 	/**#@-*/
@@ -158,14 +170,16 @@  discard block
 block discarded – undo
158 170
 	/**
159 171
 	 * Send a POST request
160 172
 	 */
161
-	public function post($url, $headers = array(), $data = array(), $options = array()) {
173
+	public function post($url, $headers = array(), $data = array(), $options = array())
174
+	{
162 175
 		return $this->request($url, $headers, $data, Requests::POST, $options);
163 176
 	}
164 177
 
165 178
 	/**
166 179
 	 * Send a PUT request
167 180
 	 */
168
-	public function put($url, $headers = array(), $data = array(), $options = array()) {
181
+	public function put($url, $headers = array(), $data = array(), $options = array())
182
+	{
169 183
 		return $this->request($url, $headers, $data, Requests::PUT, $options);
170 184
 	}
171 185
 
@@ -177,7 +191,8 @@  discard block
 block discarded – undo
177 191
 	 *
178 192
 	 * @link https://tools.ietf.org/html/rfc5789
179 193
 	 */
180
-	public function patch($url, $headers, $data = array(), $options = array()) {
194
+	public function patch($url, $headers, $data = array(), $options = array())
195
+	{
181 196
 		return $this->request($url, $headers, $data, Requests::PATCH, $options);
182 197
 	}
183 198
 	/**#@-*/
@@ -199,7 +214,8 @@  discard block
 block discarded – undo
199 214
 	 * @param array $options Options for the request (see {@see Requests::request})
200 215
 	 * @return Requests_Response
201 216
 	 */
202
-	public function request($url, $headers = array(), $data = array(), $type = Requests::GET, $options = array()) {
217
+	public function request($url, $headers = array(), $data = array(), $type = Requests::GET, $options = array())
218
+	{
203 219
 		$request = $this->merge_request(compact('url', 'headers', 'data', 'options'));
204 220
 
205 221
 		return Requests::request($request['url'], $request['headers'], $request['data'], $type, $request['options']);
@@ -214,8 +230,10 @@  discard block
 block discarded – undo
214 230
 	 * @param array $options Global and default options (see {@see Requests::request})
215 231
 	 * @return array Responses (either Requests_Response or a Requests_Exception object)
216 232
 	 */
217
-	public function request_multiple($requests, $options = array()) {
218
-		foreach ($requests as $key => $request) {
233
+	public function request_multiple($requests, $options = array())
234
+	{
235
+		foreach ($requests as $key => $request)
236
+		{
219 237
 			$requests[$key] = $this->merge_request($request, false);
220 238
 		}
221 239
 
@@ -234,27 +252,34 @@  discard block
 block discarded – undo
234 252
 	 * @param boolean $merge_options Should we merge options as well?
235 253
 	 * @return array Request data
236 254
 	 */
237
-	protected function merge_request($request, $merge_options = true) {
238
-		if ($this->url !== null) {
255
+	protected function merge_request($request, $merge_options = true)
256
+	{
257
+		if ($this->url !== null)
258
+		{
239 259
 			$request['url'] = Requests_IRI::absolutize($this->url, $request['url']);
240 260
 			$request['url'] = $request['url']->uri;
241 261
 		}
242 262
 
243
-		if (empty($request['headers'])) {
263
+		if (empty($request['headers']))
264
+		{
244 265
 			$request['headers'] = array();
245 266
 		}
246 267
 		$request['headers'] = array_merge($this->headers, $request['headers']);
247 268
 
248
-		if (empty($request['data'])) {
249
-			if (is_array($this->data)) {
269
+		if (empty($request['data']))
270
+		{
271
+			if (is_array($this->data))
272
+			{
250 273
 				$request['data'] = $this->data;
251 274
 			}
252 275
 		}
253
-		elseif (is_array($request['data']) && is_array($this->data)) {
276
+		elseif (is_array($request['data']) && is_array($this->data))
277
+		{
254 278
 			$request['data'] = array_merge($this->data, $request['data']);
255 279
 		}
256 280
 
257
-		if ($merge_options !== false) {
281
+		if ($merge_options !== false)
282
+		{
258 283
 			$request['options'] = array_merge($this->options, $request['options']);
259 284
 
260 285
 			// Disallow forcing the type, as that's a per request setting
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Transport.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
  * @package Requests
13 13
  * @subpackage Transport
14 14
  */
15
-interface Requests_Transport {
15
+interface Requests_Transport
16
+{
16 17
 	/**
17 18
 	 * Perform a request
18 19
 	 *
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Utility/CaseInsensitiveDictionary.php 1 patch
Braces   +20 added lines, -10 removed lines patch added patch discarded remove patch
@@ -25,8 +25,10 @@  discard block
 block discarded – undo
25 25
 	 *
26 26
 	 * @param array $data Dictionary/map to convert to case-insensitive
27 27
 	 */
28
-	public function __construct(array $data = array()) {
29
-		foreach ($data as $key => $value) {
28
+	public function __construct(array $data = array())
29
+	{
30
+		foreach ($data as $key => $value)
31
+		{
30 32
 			$this->offsetSet($key, $value);
31 33
 		}
32 34
 	}
@@ -37,7 +39,8 @@  discard block
 block discarded – undo
37 39
 	 * @param string $key Item key
38 40
 	 * @return boolean Does the item exist?
39 41
 	 */
40
-	public function offsetExists($key) {
42
+	public function offsetExists($key)
43
+	{
41 44
 		$key = strtolower($key);
42 45
 		return isset($this->data[$key]);
43 46
 	}
@@ -48,9 +51,11 @@  discard block
 block discarded – undo
48 51
 	 * @param string $key Item key
49 52
 	 * @return string Item value
50 53
 	 */
51
-	public function offsetGet($key) {
54
+	public function offsetGet($key)
55
+	{
52 56
 		$key = strtolower($key);
53
-		if (!isset($this->data[$key])) {
57
+		if (!isset($this->data[$key]))
58
+		{
54 59
 			return null;
55 60
 		}
56 61
 
@@ -65,8 +70,10 @@  discard block
 block discarded – undo
65 70
 	 * @param string $key Item name
66 71
 	 * @param string $value Item value
67 72
 	 */
68
-	public function offsetSet($key, $value) {
69
-		if ($key === null) {
73
+	public function offsetSet($key, $value)
74
+	{
75
+		if ($key === null)
76
+		{
70 77
 			throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset');
71 78
 		}
72 79
 
@@ -79,7 +86,8 @@  discard block
 block discarded – undo
79 86
 	 *
80 87
 	 * @param string $key
81 88
 	 */
82
-	public function offsetUnset($key) {
89
+	public function offsetUnset($key)
90
+	{
83 91
 		unset($this->data[strtolower($key)]);
84 92
 	}
85 93
 
@@ -88,7 +96,8 @@  discard block
 block discarded – undo
88 96
 	 *
89 97
 	 * @return ArrayIterator
90 98
 	 */
91
-	public function getIterator() {
99
+	public function getIterator()
100
+	{
92 101
 		return new ArrayIterator($this->data);
93 102
 	}
94 103
 
@@ -97,7 +106,8 @@  discard block
 block discarded – undo
97 106
 	 *
98 107
 	 * @return array Header data
99 108
 	 */
100
-	public function getAll() {
109
+	public function getAll()
110
+	{
101 111
 		return $this->data;
102 112
 	}
103 113
 }
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Utility/FilteredIterator.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@  discard block
 block discarded – undo
12 12
  * @package Requests
13 13
  * @subpackage Utilities
14 14
  */
15
-class Requests_Utility_FilteredIterator extends ArrayIterator {
15
+class Requests_Utility_FilteredIterator extends ArrayIterator
16
+{
16 17
 	/**
17 18
 	 * Callback to run as a filter
18 19
 	 *
@@ -26,7 +27,8 @@  discard block
 block discarded – undo
26 27
 	 * @param array $data
27 28
 	 * @param callable $callback Callback to be called on each value
28 29
 	 */
29
-	public function __construct($data, $callback) {
30
+	public function __construct($data, $callback)
31
+	{
30 32
 		parent::__construct($data);
31 33
 
32 34
 		$this->callback = $callback;
@@ -37,7 +39,8 @@  discard block
 block discarded – undo
37 39
 	 *
38 40
 	 * @return string
39 41
 	 */
40
-	public function current() {
42
+	public function current()
43
+	{
41 44
 		$value = parent::current();
42 45
 		$value = call_user_func($this->callback, $value);
43 46
 		return $value;
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Exception/Transport/cURL.php 1 patch
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class Requests_Exception_Transport_cURL extends Requests_Exception_Transport {
3
+class Requests_Exception_Transport_cURL extends Requests_Exception_Transport
4
+{
4 5
 
5 6
 	const EASY = 'cURLEasy';
6 7
 	const MULTI = 'cURLMulti';
@@ -29,16 +30,20 @@  discard block
 block discarded – undo
29 30
 	 */
30 31
 	protected $reason = 'Unknown';
31 32
 
32
-	public function __construct($message, $type, $data = null, $code = 0) {
33
-		if ($type !== null) {
33
+	public function __construct($message, $type, $data = null, $code = 0)
34
+	{
35
+		if ($type !== null)
36
+		{
34 37
 			$this->type = $type;
35 38
 		}
36 39
 
37
-		if ($code !== null) {
40
+		if ($code !== null)
41
+		{
38 42
 			$this->code = $code;
39 43
 		}
40 44
 
41
-		if ($message !== null) {
45
+		if ($message !== null)
46
+		{
42 47
 			$this->reason = $message;
43 48
 		}
44 49
 
@@ -49,7 +54,8 @@  discard block
 block discarded – undo
49 54
 	/**
50 55
 	 * Get the error message
51 56
 	 */
52
-	public function getReason() {
57
+	public function getReason()
58
+	{
53 59
 		return $this->reason;
54 60
 	}
55 61
 
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Exception/Transport.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-class Requests_Exception_Transport extends Requests_Exception {
3
+class Requests_Exception_Transport extends Requests_Exception
4
+{
4 5
 
5 6
 }
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Exception/HTTP.php 1 patch
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,7 +10,8 @@  discard block
 block discarded – undo
10 10
  *
11 11
  * @package Requests
12 12
  */
13
-class Requests_Exception_HTTP extends Requests_Exception {
13
+class Requests_Exception_HTTP extends Requests_Exception
14
+{
14 15
 	/**
15 16
 	 * HTTP status code
16 17
 	 *
@@ -34,8 +35,10 @@  discard block
 block discarded – undo
34 35
 	 * @param string|null $reason Reason phrase
35 36
 	 * @param mixed $data Associated data
36 37
 	 */
37
-	public function __construct($reason = null, $data = null) {
38
-		if ($reason !== null) {
38
+	public function __construct($reason = null, $data = null)
39
+	{
40
+		if ($reason !== null)
41
+		{
39 42
 			$this->reason = $reason;
40 43
 		}
41 44
 
@@ -46,7 +49,8 @@  discard block
 block discarded – undo
46 49
 	/**
47 50
 	 * Get the status message
48 51
 	 */
49
-	public function getReason() {
52
+	public function getReason()
53
+	{
50 54
 		return $this->reason;
51 55
 	}
52 56
 
@@ -56,13 +60,16 @@  discard block
 block discarded – undo
56 60
 	 * @param int|bool $code HTTP status code, or false if unavailable
57 61
 	 * @return string Exception class name to use
58 62
 	 */
59
-	public static function get_class($code) {
60
-		if (!$code) {
63
+	public static function get_class($code)
64
+	{
65
+		if (!$code)
66
+		{
61 67
 			return 'Requests_Exception_HTTP_Unknown';
62 68
 		}
63 69
 
64 70
 		$class = sprintf('Requests_Exception_HTTP_%d', $code);
65
-		if (class_exists($class)) {
71
+		if (class_exists($class))
72
+		{
66 73
 			return $class;
67 74
 		}
68 75
 
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Exception/HTTP/414.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,8 @@
 block discarded – undo
10 10
  *
11 11
  * @package Requests
12 12
  */
13
-class Requests_Exception_HTTP_414 extends Requests_Exception_HTTP {
13
+class Requests_Exception_HTTP_414 extends Requests_Exception_HTTP
14
+{
14 15
 	/**
15 16
 	 * HTTP status code
16 17
 	 *
Please login to merge, or discard this patch.