15 $msg =
"$domain against origin $origin";
20 $this->assertEquals( $expected, $ok, $msg );
27 [
true,
"wikipedia.org" ],
28 [
true,
".wikipedia.org" ],
33 [
true,
"supermarket.uk" ],
36 [
false,
"127.0.0." ],
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" ],
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" ],
77 $this->
setMwGlobals(
'wgHTTPProxy',
'proxy.domain.tld' );
90 [
false,
'¿non sens before!! http://a',
'Allow anything before URI' ],
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' ],
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' ],
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' ],
114 # (\S+) - host part is made of anything not whitespaces
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/' ],
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/&' ],
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' ],
147 [
false,
'http://a ¿non !!sens after',
'Allow anything after URI' ],
154 'location' => [
'http://newsite/file.ext',
'/newfile.ext' ],
155 'final' =>
'http://newsite/newfile.ext',
156 'Relative file path Location: interpreted as full URL'
159 'location' => [
'https://oldsite/file.ext' ],
160 'final' =>
'https://oldsite/file.ext',
161 'Location to the HTTPS version of the site'
166 'http://anotherfile/hoster.ext',
167 'https://anotherfile/hoster.ext'
169 'final' =>
'https://anotherfile/hoster.ext',
170 'Relative file path Location: should keep the latest host and scheme!'
173 'location' => [
'/anotherfile.ext' ],
174 'final' =>
'http://oldsite/anotherfile.ext',
175 'Relative Location without domain '
179 'final' =>
'http://oldsite/file.ext',
180 'No Location (no redirect) '
198 $h->setRespHeaders(
'location', $location );
200 $this->assertEquals( $final, $h->getFinalUrl(), $message );
222 [
'CURLAUTH_ANYSAFE' ],
223 [
'CURLAUTH_BASIC' ],
224 [
'CURLAUTH_DIGEST' ],
225 [
'CURLAUTH_GSSNEGOTIATE' ],
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' ],
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' ],
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' ],
304 [
'CURLFTPSSL_ALL' ],
305 [
'CURLFTPSSL_CONTROL' ],
306 [
'CURLFTPSSL_NONE' ],
307 [
'CURLFTPSSL_TRY' ],
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' ],
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' ],
333 [
'CURLM_BAD_EASY_HANDLE' ],
334 [
'CURLM_BAD_HANDLE' ],
335 [
'CURLM_CALL_MULTI_PERFORM' ],
336 [
'CURLM_INTERNAL_ERROR' ],
338 [
'CURLM_OUT_OF_MEMORY' ],
339 [
'CURLOPT_AUTOREFERER' ],
340 [
'CURLOPT_BINARYTRANSFER' ],
341 [
'CURLOPT_BUFFERSIZE' ],
342 [
'CURLOPT_CAINFO' ],
343 [
'CURLOPT_CAPATH' ],
346 [
'CURLOPT_CONNECTTIMEOUT' ],
347 [
'CURLOPT_CONNECTTIMEOUT_MS' ],
348 [
'CURLOPT_COOKIE' ],
349 [
'CURLOPT_COOKIEFILE' ],
350 [
'CURLOPT_COOKIEJAR' ],
351 [
'CURLOPT_COOKIESESSION' ],
353 [
'CURLOPT_CUSTOMREQUEST' ],
354 [
'CURLOPT_DNS_CACHE_TIMEOUT' ],
355 [
'CURLOPT_DNS_USE_GLOBAL_CACHE' ],
356 [
'CURLOPT_EGDSOCKET' ],
357 [
'CURLOPT_ENCODING' ],
358 [
'CURLOPT_FAILONERROR' ],
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' ],
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' ],
387 [
'CURLOPT_KRB4LEVEL' ],
388 [
'CURLOPT_LOW_SPEED_LIMIT' ],
389 [
'CURLOPT_LOW_SPEED_TIME' ],
390 [
'CURLOPT_MAXCONNECTS' ],
391 [
'CURLOPT_MAXREDIRS' ],
395 [
'CURLOPT_NOBODY' ],
396 [
'CURLOPT_NOPROGRESS' ],
397 [
'CURLOPT_NOSIGNAL' ],
400 [
'CURLOPT_POSTFIELDS' ],
401 [
'CURLOPT_POSTQUOTE' ],
402 [
'CURLOPT_POSTREDIR' ],
403 [
'CURLOPT_PRIVATE' ],
404 [
'CURLOPT_PROGRESSFUNCTION' ],
407 [
'CURLOPT_PROXYAUTH' ],
408 [
'CURLOPT_PROXYPORT' ],
409 [
'CURLOPT_PROXYTYPE' ],
410 [
'CURLOPT_PROXYUSERPWD' ],
413 [
'CURLOPT_RANDOM_FILE' ],
415 [
'CURLOPT_READDATA' ],
416 [
'CURLOPT_READFUNCTION' ],
418 [
'CURLOPT_REFERER' ],
419 [
'CURLOPT_RESUME_FROM' ],
420 [
'CURLOPT_RETURNTRANSFER' ],
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' ],
447 [
'CURLOPT_USERAGENT' ],
448 [
'CURLOPT_USERPWD' ],
449 [
'CURLOPT_VERBOSE' ],
450 [
'CURLOPT_WRITEFUNCTION' ],
451 [
'CURLOPT_WRITEHEADER' ],
465 [
'CURLPROXY_HTTP' ],
467 [
'CURLPROXY_SOCKS5' ],
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' ],
504 $this->assertTrue( defined(
$value ),
$value .
' not defined' );
518 throw new DomainException( __METHOD__ .
': curl (http://php.net/curl) is not installed, but' .
519 'Http::$httpEngine is set to "curl"' );
527 throw new DomainException( __METHOD__ .
528 ': allow_url_fopen needs to be enabled for pure PHP HTTP requests to work. '
529 .
'If possible, curl should be used instead. See http://php.net/curl.' );
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.
setRespHeaders( $name, $value)
MWHttpRequest implemented using internal curl compiled into PHP.
testRelativeRedirections( $location, $final, $message=null)
Warning:
testCurlConstants( $value)
Added this test based on an issue experienced with HHVM 3.3.0-dev where it did not define a cURL cons...
static provideURI()
Feeds URI to test a long regular expression in Http::isValidURI.
testIsValidUri( $expect, $URI, $message='')
Test Http::isValidURI() T29854 : Http::isValidURI is too lax provideURI Http::isValidURI.
testValidateCookieDomain( $expected, $domain, $origin=null)
cookieDomains Cookie::validateCookieDomain
testGetProxy()
Http::getProxy.
provideCurlConstants()
Constant values are from PHP 5.3.28 using cURL 7.24.0.
static provideRelativeRedirects()
static isValidURI( $uri)
Checks that the given URI is a valid one.
static getProxy()
Gets the relevant proxy from $wgHTTPProxy.
Class to let us overwrite MWHttpRequest respHeaders variable.
static factory( $url, array $options=null, $caller=__METHOD__)
Generate a new request object Deprecated:
This wrapper class will call out to curl (if available) or fallback to regular PHP if necessary for h...
setRespHeaders( $name, $value)
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
Allows to change the fields on the form that will be generated $name