MediaWiki REL1_33
HttpTest.php
Go to the documentation of this file.
1<?php
2
12 public function testValidateCookieDomain( $expected, $domain, $origin = null ) {
13 if ( $origin ) {
14 $ok = Cookie::validateCookieDomain( $domain, $origin );
15 $msg = "$domain against origin $origin";
16 } else {
17 $ok = Cookie::validateCookieDomain( $domain );
18 $msg = "$domain";
19 }
20 $this->assertEquals( $expected, $ok, $msg );
21 }
22
23 public static function cookieDomains() {
24 return [
25 [ false, "org" ],
26 [ false, ".org" ],
27 [ true, "wikipedia.org" ],
28 [ true, ".wikipedia.org" ],
29 [ false, "co.uk" ],
30 [ false, ".co.uk" ],
31 [ false, "gov.uk" ],
32 [ false, ".gov.uk" ],
33 [ true, "supermarket.uk" ],
34 [ false, "uk" ],
35 [ false, ".uk" ],
36 [ false, "127.0.0." ],
37 [ false, "127." ],
38 [ false, "127.0.0.1." ],
39 [ true, "127.0.0.1" ],
40 [ false, "333.0.0.1" ],
41 [ true, "example.com" ],
42 [ false, "example.com." ],
43 [ true, ".example.com" ],
44
45 [ true, ".example.com", "www.example.com" ],
46 [ false, "example.com", "www.example.com" ],
47 [ true, "127.0.0.1", "127.0.0.1" ],
48 [ false, "127.0.0.1", "localhost" ],
49 ];
50 }
51
58 public function testIsValidUri( $expect, $URI, $message = '' ) {
59 $this->assertEquals(
60 $expect,
61 (bool)Http::isValidURI( $URI ),
62 $message
63 );
64 }
65
69 public function testGetProxy() {
70 $this->setMwGlobals( 'wgHTTPProxy', false );
71 $this->assertEquals(
72 '',
74 'default setting'
75 );
76
77 $this->setMwGlobals( 'wgHTTPProxy', 'proxy.domain.tld' );
78 $this->assertEquals(
79 'proxy.domain.tld',
81 );
82 }
83
87 public static function provideURI() {
89 return [
90 [ false, '¿non sens before!! http://a', 'Allow anything before URI' ],
91
92 # (http|https) - only two schemes allowed
93 [ true, 'http://www.example.org/' ],
94 [ true, 'https://www.example.org/' ],
95 [ true, 'http://www.example.org', 'URI without directory' ],
96 [ true, 'http://a', 'Short name' ],
97 [ true, 'http://étoile', 'Allow UTF-8 in hostname' ], # 'étoile' is french for 'star'
98 [ false, '\\host\directory', 'CIFS share' ],
99 [ false, 'gopher://host/dir', 'Reject gopher scheme' ],
100 [ false, 'telnet://host', 'Reject telnet scheme' ],
101
102 # :\/\/ - double slashes
103 [ false, 'http//example.org', 'Reject missing colon in protocol' ],
104 [ false, 'http:/example.org', 'Reject missing slash in protocol' ],
105 [ false, 'http:example.org', 'Must have two slashes' ],
106 # Following fail since hostname can be made of anything
107 [ false, 'http:///example.org', 'Must have exactly two slashes, not three' ],
108
109 # (\w+:{0,1}\w*@)? - optional user:pass
110 [ true, 'http://user@host', 'Username provided' ],
111 [ true, 'http://user:@host', 'Username provided, no password' ],
112 [ true, 'http://user:pass@host', 'Username and password provided' ],
113
114 # (\S+) - host part is made of anything not whitespaces
115 // commented these out in order to remove @group Broken
116 // @todo are these valid tests? if so, fix Http::isValidURI so it can handle them
117 // [ false, 'http://!"èèè¿¿¿~~\'', 'hostname is made of any non whitespace' ],
118 // [ false, 'http://exam:ple.org/', 'hostname can not use colons!' ],
119
120 # (:[0-9]+)? - port number
121 [ true, 'http://example.org:80/' ],
122 [ true, 'https://example.org:80/' ],
123 [ true, 'http://example.org:443/' ],
124 [ true, 'https://example.org:443/' ],
125
126 # Part after the hostname is / or / with something else
127 [ true, 'http://example/#' ],
128 [ true, 'http://example/!' ],
129 [ true, 'http://example/:' ],
130 [ true, 'http://example/.' ],
131 [ true, 'http://example/?' ],
132 [ true, 'http://example/+' ],
133 [ true, 'http://example/=' ],
134 [ true, 'http://example/&' ],
135 [ true, 'http://example/%' ],
136 [ true, 'http://example/@' ],
137 [ true, 'http://example/-' ],
138 [ true, 'http://example//' ],
139 [ true, 'http://example/&' ],
140
141 # Fragment
142 [ true, 'http://exam#ple.org', ], # This one is valid, really!
143 [ true, 'http://example.org:80#anchor' ],
144 [ true, 'http://example.org/?id#anchor' ],
145 [ true, 'http://example.org/?#anchor' ],
146
147 [ false, 'http://a ¿non !!sens after', 'Allow anything after URI' ],
148 ];
149 }
150
151 public static function provideRelativeRedirects() {
152 return [
153 [
154 'location' => [ 'http://newsite/file.ext', '/newfile.ext' ],
155 'final' => 'http://newsite/newfile.ext',
156 'Relative file path Location: interpreted as full URL'
157 ],
158 [
159 'location' => [ 'https://oldsite/file.ext' ],
160 'final' => 'https://oldsite/file.ext',
161 'Location to the HTTPS version of the site'
162 ],
163 [
164 'location' => [
165 '/anotherfile.ext',
166 'http://anotherfile/hoster.ext',
167 'https://anotherfile/hoster.ext'
168 ],
169 'final' => 'https://anotherfile/hoster.ext',
170 'Relative file path Location: should keep the latest host and scheme!'
171 ],
172 [
173 'location' => [ '/anotherfile.ext' ],
174 'final' => 'http://oldsite/anotherfile.ext',
175 'Relative Location without domain '
176 ],
177 [
178 'location' => null,
179 'final' => 'http://oldsite/file.ext',
180 'No Location (no redirect) '
181 ],
182 ];
183 }
184
195 public function testRelativeRedirections( $location, $final, $message = null ) {
196 $h = MWHttpRequestTester::factory( 'http://oldsite/file.ext', [], __METHOD__ );
197 // Forge a Location header
198 $h->setRespHeaders( 'location', $location );
199 // Verify it correctly fixes the Location
200 $this->assertEquals( $final, $h->getFinalUrl(), $message );
201 }
202
219 public function provideCurlConstants() {
220 return [
221 [ 'CURLAUTH_ANY' ],
222 [ 'CURLAUTH_ANYSAFE' ],
223 [ 'CURLAUTH_BASIC' ],
224 [ 'CURLAUTH_DIGEST' ],
225 [ 'CURLAUTH_GSSNEGOTIATE' ],
226 [ 'CURLAUTH_NTLM' ],
227 // [ 'CURLCLOSEPOLICY_CALLBACK' ], // removed in PHP 5.6.0
228 // [ 'CURLCLOSEPOLICY_LEAST_RECENTLY_USED' ], // removed in PHP 5.6.0
229 // [ 'CURLCLOSEPOLICY_LEAST_TRAFFIC' ], // removed in PHP 5.6.0
230 // [ 'CURLCLOSEPOLICY_OLDEST' ], // removed in PHP 5.6.0
231 // [ 'CURLCLOSEPOLICY_SLOWEST' ], // removed in PHP 5.6.0
232 [ 'CURLE_ABORTED_BY_CALLBACK' ],
233 [ 'CURLE_BAD_CALLING_ORDER' ],
234 [ 'CURLE_BAD_CONTENT_ENCODING' ],
235 [ 'CURLE_BAD_FUNCTION_ARGUMENT' ],
236 [ 'CURLE_BAD_PASSWORD_ENTERED' ],
237 [ 'CURLE_COULDNT_CONNECT' ],
238 [ 'CURLE_COULDNT_RESOLVE_HOST' ],
239 [ 'CURLE_COULDNT_RESOLVE_PROXY' ],
240 [ 'CURLE_FAILED_INIT' ],
241 [ 'CURLE_FILESIZE_EXCEEDED' ],
242 [ 'CURLE_FILE_COULDNT_READ_FILE' ],
243 [ 'CURLE_FTP_ACCESS_DENIED' ],
244 [ 'CURLE_FTP_BAD_DOWNLOAD_RESUME' ],
245 [ 'CURLE_FTP_CANT_GET_HOST' ],
246 [ 'CURLE_FTP_CANT_RECONNECT' ],
247 [ 'CURLE_FTP_COULDNT_GET_SIZE' ],
248 [ 'CURLE_FTP_COULDNT_RETR_FILE' ],
249 [ 'CURLE_FTP_COULDNT_SET_ASCII' ],
250 [ 'CURLE_FTP_COULDNT_SET_BINARY' ],
251 [ 'CURLE_FTP_COULDNT_STOR_FILE' ],
252 [ 'CURLE_FTP_COULDNT_USE_REST' ],
253 [ 'CURLE_FTP_PORT_FAILED' ],
254 [ 'CURLE_FTP_QUOTE_ERROR' ],
255 [ 'CURLE_FTP_SSL_FAILED' ],
256 [ 'CURLE_FTP_USER_PASSWORD_INCORRECT' ],
257 [ 'CURLE_FTP_WEIRD_227_FORMAT' ],
258 [ 'CURLE_FTP_WEIRD_PASS_REPLY' ],
259 [ 'CURLE_FTP_WEIRD_PASV_REPLY' ],
260 [ 'CURLE_FTP_WEIRD_SERVER_REPLY' ],
261 [ 'CURLE_FTP_WEIRD_USER_REPLY' ],
262 [ 'CURLE_FTP_WRITE_ERROR' ],
263 [ 'CURLE_FUNCTION_NOT_FOUND' ],
264 [ 'CURLE_GOT_NOTHING' ],
265 [ 'CURLE_HTTP_NOT_FOUND' ],
266 [ 'CURLE_HTTP_PORT_FAILED' ],
267 [ 'CURLE_HTTP_POST_ERROR' ],
268 [ 'CURLE_HTTP_RANGE_ERROR' ],
269 [ 'CURLE_LDAP_CANNOT_BIND' ],
270 [ 'CURLE_LDAP_INVALID_URL' ],
271 [ 'CURLE_LDAP_SEARCH_FAILED' ],
272 [ 'CURLE_LIBRARY_NOT_FOUND' ],
273 [ 'CURLE_MALFORMAT_USER' ],
274 [ 'CURLE_OBSOLETE' ],
275 [ 'CURLE_OK' ],
276 [ 'CURLE_OPERATION_TIMEOUTED' ],
277 [ 'CURLE_OUT_OF_MEMORY' ],
278 [ 'CURLE_PARTIAL_FILE' ],
279 [ 'CURLE_READ_ERROR' ],
280 [ 'CURLE_RECV_ERROR' ],
281 [ 'CURLE_SEND_ERROR' ],
282 [ 'CURLE_SHARE_IN_USE' ],
283 // [ 'CURLE_SSH' ], // not present in HHVM 3.3.0-dev
284 [ 'CURLE_SSL_CACERT' ],
285 [ 'CURLE_SSL_CERTPROBLEM' ],
286 [ 'CURLE_SSL_CIPHER' ],
287 [ 'CURLE_SSL_CONNECT_ERROR' ],
288 [ 'CURLE_SSL_ENGINE_NOTFOUND' ],
289 [ 'CURLE_SSL_ENGINE_SETFAILED' ],
290 [ 'CURLE_SSL_PEER_CERTIFICATE' ],
291 [ 'CURLE_TELNET_OPTION_SYNTAX' ],
292 [ 'CURLE_TOO_MANY_REDIRECTS' ],
293 [ 'CURLE_UNKNOWN_TELNET_OPTION' ],
294 [ 'CURLE_UNSUPPORTED_PROTOCOL' ],
295 [ 'CURLE_URL_MALFORMAT' ],
296 [ 'CURLE_URL_MALFORMAT_USER' ],
297 [ 'CURLE_WRITE_ERROR' ],
298 [ 'CURLFTPAUTH_DEFAULT' ],
299 [ 'CURLFTPAUTH_SSL' ],
300 [ 'CURLFTPAUTH_TLS' ],
301 // [ 'CURLFTPMETHOD_MULTICWD' ], // not present in HHVM 3.3.0-dev
302 // [ 'CURLFTPMETHOD_NOCWD' ], // not present in HHVM 3.3.0-dev
303 // [ 'CURLFTPMETHOD_SINGLECWD' ], // not present in HHVM 3.3.0-dev
304 [ 'CURLFTPSSL_ALL' ],
305 [ 'CURLFTPSSL_CONTROL' ],
306 [ 'CURLFTPSSL_NONE' ],
307 [ 'CURLFTPSSL_TRY' ],
308 // [ 'CURLINFO_CERTINFO' ], // not present in HHVM 3.3.0-dev
309 [ 'CURLINFO_CONNECT_TIME' ],
310 [ 'CURLINFO_CONTENT_LENGTH_DOWNLOAD' ],
311 [ 'CURLINFO_CONTENT_LENGTH_UPLOAD' ],
312 [ 'CURLINFO_CONTENT_TYPE' ],
313 [ 'CURLINFO_EFFECTIVE_URL' ],
314 [ 'CURLINFO_FILETIME' ],
315 [ 'CURLINFO_HEADER_OUT' ],
316 [ 'CURLINFO_HEADER_SIZE' ],
317 [ 'CURLINFO_HTTP_CODE' ],
318 [ 'CURLINFO_NAMELOOKUP_TIME' ],
319 [ 'CURLINFO_PRETRANSFER_TIME' ],
320 [ 'CURLINFO_PRIVATE' ],
321 [ 'CURLINFO_REDIRECT_COUNT' ],
322 [ 'CURLINFO_REDIRECT_TIME' ],
323 // [ 'CURLINFO_REDIRECT_URL' ], // not present in HHVM 3.3.0-dev
324 [ 'CURLINFO_REQUEST_SIZE' ],
325 [ 'CURLINFO_SIZE_DOWNLOAD' ],
326 [ 'CURLINFO_SIZE_UPLOAD' ],
327 [ 'CURLINFO_SPEED_DOWNLOAD' ],
328 [ 'CURLINFO_SPEED_UPLOAD' ],
329 [ 'CURLINFO_SSL_VERIFYRESULT' ],
330 [ 'CURLINFO_STARTTRANSFER_TIME' ],
331 [ 'CURLINFO_TOTAL_TIME' ],
332 [ 'CURLMSG_DONE' ],
333 [ 'CURLM_BAD_EASY_HANDLE' ],
334 [ 'CURLM_BAD_HANDLE' ],
335 [ 'CURLM_CALL_MULTI_PERFORM' ],
336 [ 'CURLM_INTERNAL_ERROR' ],
337 [ 'CURLM_OK' ],
338 [ 'CURLM_OUT_OF_MEMORY' ],
339 [ 'CURLOPT_AUTOREFERER' ],
340 [ 'CURLOPT_BINARYTRANSFER' ],
341 [ 'CURLOPT_BUFFERSIZE' ],
342 [ 'CURLOPT_CAINFO' ],
343 [ 'CURLOPT_CAPATH' ],
344 // [ 'CURLOPT_CERTINFO' ], // not present in HHVM 3.3.0-dev
345 // [ 'CURLOPT_CLOSEPOLICY' ], // removed in PHP 5.6.0
346 [ 'CURLOPT_CONNECTTIMEOUT' ],
347 [ 'CURLOPT_CONNECTTIMEOUT_MS' ],
348 [ 'CURLOPT_COOKIE' ],
349 [ 'CURLOPT_COOKIEFILE' ],
350 [ 'CURLOPT_COOKIEJAR' ],
351 [ 'CURLOPT_COOKIESESSION' ],
352 [ 'CURLOPT_CRLF' ],
353 [ 'CURLOPT_CUSTOMREQUEST' ],
354 [ 'CURLOPT_DNS_CACHE_TIMEOUT' ],
355 [ 'CURLOPT_DNS_USE_GLOBAL_CACHE' ],
356 [ 'CURLOPT_EGDSOCKET' ],
357 [ 'CURLOPT_ENCODING' ],
358 [ 'CURLOPT_FAILONERROR' ],
359 [ 'CURLOPT_FILE' ],
360 [ 'CURLOPT_FILETIME' ],
361 [ 'CURLOPT_FOLLOWLOCATION' ],
362 [ 'CURLOPT_FORBID_REUSE' ],
363 [ 'CURLOPT_FRESH_CONNECT' ],
364 [ 'CURLOPT_FTPAPPEND' ],
365 [ 'CURLOPT_FTPLISTONLY' ],
366 [ 'CURLOPT_FTPPORT' ],
367 [ 'CURLOPT_FTPSSLAUTH' ],
368 [ 'CURLOPT_FTP_CREATE_MISSING_DIRS' ],
369 // [ 'CURLOPT_FTP_FILEMETHOD' ], // not present in HHVM 3.3.0-dev
370 // [ 'CURLOPT_FTP_SKIP_PASV_IP' ], // not present in HHVM 3.3.0-dev
371 [ 'CURLOPT_FTP_SSL' ],
372 [ 'CURLOPT_FTP_USE_EPRT' ],
373 [ 'CURLOPT_FTP_USE_EPSV' ],
374 [ 'CURLOPT_HEADER' ],
375 [ 'CURLOPT_HEADERFUNCTION' ],
376 [ 'CURLOPT_HTTP200ALIASES' ],
377 [ 'CURLOPT_HTTPAUTH' ],
378 [ 'CURLOPT_HTTPGET' ],
379 [ 'CURLOPT_HTTPHEADER' ],
380 [ 'CURLOPT_HTTPPROXYTUNNEL' ],
381 [ 'CURLOPT_HTTP_VERSION' ],
382 [ 'CURLOPT_INFILE' ],
383 [ 'CURLOPT_INFILESIZE' ],
384 [ 'CURLOPT_INTERFACE' ],
385 [ 'CURLOPT_IPRESOLVE' ],
386 // [ 'CURLOPT_KEYPASSWD' ], // not present in HHVM 3.3.0-dev
387 [ 'CURLOPT_KRB4LEVEL' ],
388 [ 'CURLOPT_LOW_SPEED_LIMIT' ],
389 [ 'CURLOPT_LOW_SPEED_TIME' ],
390 [ 'CURLOPT_MAXCONNECTS' ],
391 [ 'CURLOPT_MAXREDIRS' ],
392 // [ 'CURLOPT_MAX_RECV_SPEED_LARGE' ], // not present in HHVM 3.3.0-dev
393 // [ 'CURLOPT_MAX_SEND_SPEED_LARGE' ], // not present in HHVM 3.3.0-dev
394 [ 'CURLOPT_NETRC' ],
395 [ 'CURLOPT_NOBODY' ],
396 [ 'CURLOPT_NOPROGRESS' ],
397 [ 'CURLOPT_NOSIGNAL' ],
398 [ 'CURLOPT_PORT' ],
399 [ 'CURLOPT_POST' ],
400 [ 'CURLOPT_POSTFIELDS' ],
401 [ 'CURLOPT_POSTQUOTE' ],
402 [ 'CURLOPT_POSTREDIR' ],
403 [ 'CURLOPT_PRIVATE' ],
404 [ 'CURLOPT_PROGRESSFUNCTION' ],
405 // [ 'CURLOPT_PROTOCOLS' ], // not present in HHVM 3.3.0-dev
406 [ 'CURLOPT_PROXY' ],
407 [ 'CURLOPT_PROXYAUTH' ],
408 [ 'CURLOPT_PROXYPORT' ],
409 [ 'CURLOPT_PROXYTYPE' ],
410 [ 'CURLOPT_PROXYUSERPWD' ],
411 [ 'CURLOPT_PUT' ],
412 [ 'CURLOPT_QUOTE' ],
413 [ 'CURLOPT_RANDOM_FILE' ],
414 [ 'CURLOPT_RANGE' ],
415 [ 'CURLOPT_READDATA' ],
416 [ 'CURLOPT_READFUNCTION' ],
417 // [ 'CURLOPT_REDIR_PROTOCOLS' ], // not present in HHVM 3.3.0-dev
418 [ 'CURLOPT_REFERER' ],
419 [ 'CURLOPT_RESUME_FROM' ],
420 [ 'CURLOPT_RETURNTRANSFER' ],
421 // [ 'CURLOPT_SSH_AUTH_TYPES' ], // not present in HHVM 3.3.0-dev
422 // [ 'CURLOPT_SSH_HOST_PUBLIC_KEY_MD5' ], // not present in HHVM 3.3.0-dev
423 // [ 'CURLOPT_SSH_PRIVATE_KEYFILE' ], // not present in HHVM 3.3.0-dev
424 // [ 'CURLOPT_SSH_PUBLIC_KEYFILE' ], // not present in HHVM 3.3.0-dev
425 [ 'CURLOPT_SSLCERT' ],
426 [ 'CURLOPT_SSLCERTPASSWD' ],
427 [ 'CURLOPT_SSLCERTTYPE' ],
428 [ 'CURLOPT_SSLENGINE' ],
429 [ 'CURLOPT_SSLENGINE_DEFAULT' ],
430 [ 'CURLOPT_SSLKEY' ],
431 [ 'CURLOPT_SSLKEYPASSWD' ],
432 [ 'CURLOPT_SSLKEYTYPE' ],
433 [ 'CURLOPT_SSLVERSION' ],
434 [ 'CURLOPT_SSL_CIPHER_LIST' ],
435 [ 'CURLOPT_SSL_VERIFYHOST' ],
436 [ 'CURLOPT_SSL_VERIFYPEER' ],
437 [ 'CURLOPT_STDERR' ],
438 [ 'CURLOPT_TCP_NODELAY' ],
439 [ 'CURLOPT_TIMECONDITION' ],
440 [ 'CURLOPT_TIMEOUT' ],
441 [ 'CURLOPT_TIMEOUT_MS' ],
442 [ 'CURLOPT_TIMEVALUE' ],
443 [ 'CURLOPT_TRANSFERTEXT' ],
444 [ 'CURLOPT_UNRESTRICTED_AUTH' ],
445 [ 'CURLOPT_UPLOAD' ],
446 [ 'CURLOPT_URL' ],
447 [ 'CURLOPT_USERAGENT' ],
448 [ 'CURLOPT_USERPWD' ],
449 [ 'CURLOPT_VERBOSE' ],
450 [ 'CURLOPT_WRITEFUNCTION' ],
451 [ 'CURLOPT_WRITEHEADER' ],
452 // [ 'CURLPROTO_ALL' ], // not present in HHVM 3.3.0-dev
453 // [ 'CURLPROTO_DICT' ], // not present in HHVM 3.3.0-dev
454 // [ 'CURLPROTO_FILE' ], // not present in HHVM 3.3.0-dev
455 // [ 'CURLPROTO_FTP' ], // not present in HHVM 3.3.0-dev
456 // [ 'CURLPROTO_FTPS' ], // not present in HHVM 3.3.0-dev
457 // [ 'CURLPROTO_HTTP' ], // not present in HHVM 3.3.0-dev
458 // [ 'CURLPROTO_HTTPS' ], // not present in HHVM 3.3.0-dev
459 // [ 'CURLPROTO_LDAP' ], // not present in HHVM 3.3.0-dev
460 // [ 'CURLPROTO_LDAPS' ], // not present in HHVM 3.3.0-dev
461 // [ 'CURLPROTO_SCP' ], // not present in HHVM 3.3.0-dev
462 // [ 'CURLPROTO_SFTP' ], // not present in HHVM 3.3.0-dev
463 // [ 'CURLPROTO_TELNET' ], // not present in HHVM 3.3.0-dev
464 // [ 'CURLPROTO_TFTP' ], // not present in HHVM 3.3.0-dev
465 [ 'CURLPROXY_HTTP' ],
466 // [ 'CURLPROXY_SOCKS4' ], // not present in HHVM 3.3.0-dev
467 [ 'CURLPROXY_SOCKS5' ],
468 // [ 'CURLSSH_AUTH_DEFAULT' ], // not present in HHVM 3.3.0-dev
469 // [ 'CURLSSH_AUTH_HOST' ], // not present in HHVM 3.3.0-dev
470 // [ 'CURLSSH_AUTH_KEYBOARD' ], // not present in HHVM 3.3.0-dev
471 // [ 'CURLSSH_AUTH_NONE' ], // not present in HHVM 3.3.0-dev
472 // [ 'CURLSSH_AUTH_PASSWORD' ], // not present in HHVM 3.3.0-dev
473 // [ 'CURLSSH_AUTH_PUBLICKEY' ], // not present in HHVM 3.3.0-dev
474 [ 'CURLVERSION_NOW' ],
475 [ 'CURL_HTTP_VERSION_1_0' ],
476 [ 'CURL_HTTP_VERSION_1_1' ],
477 [ 'CURL_HTTP_VERSION_NONE' ],
478 [ 'CURL_IPRESOLVE_V4' ],
479 [ 'CURL_IPRESOLVE_V6' ],
480 [ 'CURL_IPRESOLVE_WHATEVER' ],
481 [ 'CURL_NETRC_IGNORED' ],
482 [ 'CURL_NETRC_OPTIONAL' ],
483 [ 'CURL_NETRC_REQUIRED' ],
484 [ 'CURL_TIMECOND_IFMODSINCE' ],
485 [ 'CURL_TIMECOND_IFUNMODSINCE' ],
486 [ 'CURL_TIMECOND_LASTMOD' ],
487 [ 'CURL_VERSION_IPV6' ],
488 [ 'CURL_VERSION_KERBEROS4' ],
489 [ 'CURL_VERSION_LIBZ' ],
490 [ 'CURL_VERSION_SSL' ],
491 ];
492 }
493
501 public function testCurlConstants( $value ) {
502 $this->checkPHPExtension( 'curl' );
503
504 $this->assertTrue( defined( $value ), $value . ' not defined' );
505 }
506}
507
512 // function derived from the MWHttpRequest factory function but
513 // returns appropriate tester class here
514 public static function factory( $url, array $options = null, $caller = __METHOD__ ) {
515 if ( !Http::$httpEngine ) {
516 Http::$httpEngine = 'guzzle';
517 } elseif ( Http::$httpEngine == 'curl' && !function_exists( 'curl_init' ) ) {
518 throw new DomainException( __METHOD__ . ': curl (https://secure.php.net/curl) is not ' .
519 'installed, but Http::$httpEngine is set to "curl"' );
520 }
521
522 switch ( Http::$httpEngine ) {
523 case 'guzzle':
524 return new GuzzleHttpRequestTester( $url, $options, $caller );
525 case 'curl':
526 return new CurlHttpRequestTester( $url, $options, $caller );
527 case 'php':
528 if ( !wfIniGetBool( 'allow_url_fopen' ) ) {
529 throw new DomainException( __METHOD__ .
530 ': allow_url_fopen needs to be enabled for pure PHP HTTP requests to work. '
531 . 'If possible, curl should be used instead. See https://secure.php.net/curl.' );
532 }
533
534 return new PhpHttpRequestTester( $url, $options, $caller );
535 default:
536 }
537 }
538}
539
541 function setRespHeaders( $name, $value ) {
542 $this->respHeaders[$name] = $value;
543 }
544}
545
547 function setRespHeaders( $name, $value ) {
548 $this->respHeaders[$name] = $value;
549 }
550}
551
553 function setRespHeaders( $name, $value ) {
554 $this->respHeaders[$name] = $value;
555 }
556}
wfIniGetBool( $setting)
Safety wrapper around ini_get() for boolean settings.
static validateCookieDomain( $domain, $originDomain=null)
Return the true if the cookie is valid is valid.
Definition Cookie.php:88
setRespHeaders( $name, $value)
Definition HttpTest.php:547
MWHttpRequest implemented using internal curl compiled into PHP.
setRespHeaders( $name, $value)
Definition HttpTest.php:541
MWHttpRequest implemented using the Guzzle library.
Http small.
Definition HttpTest.php:7
testRelativeRedirections( $location, $final, $message=null)
Warning:
Definition HttpTest.php:195
testCurlConstants( $value)
Added this test based on an issue experienced with HHVM 3.3.0-dev where it did not define a cURL cons...
Definition HttpTest.php:501
static provideURI()
Feeds URI to test a long regular expression in Http::isValidURI.
Definition HttpTest.php:87
testIsValidUri( $expect, $URI, $message='')
Test Http::isValidURI() T29854 : Http::isValidURI is too lax provideURI Http::isValidURI.
Definition HttpTest.php:58
testValidateCookieDomain( $expected, $domain, $origin=null)
cookieDomains Cookie::validateCookieDomain
Definition HttpTest.php:12
testGetProxy()
Http::getProxy.
Definition HttpTest.php:69
static cookieDomains()
Definition HttpTest.php:23
provideCurlConstants()
Constant values are from PHP 5.3.28 using cURL 7.24.0.
Definition HttpTest.php:219
static provideRelativeRedirects()
Definition HttpTest.php:151
static $httpEngine
Definition Http.php:28
static isValidURI( $uri)
Check that the given URI is a valid one.
Definition Http.php:149
static getProxy()
Gets the relevant proxy from $wgHTTPProxy.
Definition Http.php:161
Class to let us overwrite MWHttpRequest respHeaders variable.
Definition HttpTest.php:511
static factory( $url, array $options=null, $caller=__METHOD__)
Generate a new request object Deprecated:
Definition HttpTest.php:514
This wrapper class will call out to curl (if available) or fallback to regular PHP if necessary for h...
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
checkPHPExtension( $extName)
Check if $extName is a loaded PHP extension, will skip the test whenever it is not loaded.
setRespHeaders( $name, $value)
Definition HttpTest.php:553
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition hooks.txt:1999
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:271
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
This document provides an overview of the usage of PageUpdater and that is