* Actually removed $wgProto. * Per Aryeh's suggestions on the future of $wgServer: made $wgServer detection in DefaultSettings.php more permanent by merging it with the new code from r90105. This means that bug 14977 is properly fixed now. * Require entry points to set up the autoloader before including DefaultSettings.php. Comments on bug 14977 indicate that at some point in the past, this may have broken something. Anything that breaks now should just be fixed, we need the autoloader. Tested the most common entry points. * Since the detection code has moved from Installer to WebRequest, I also moved the relevant test file and updated the test. The function under test is now public static, so r90154 is superseded.
88 lines
1.6 KiB
PHP
88 lines
1.6 KiB
PHP
<?php
|
|
|
|
class WebRequestTest extends MediaWikiTestCase {
|
|
/**
|
|
* @dataProvider provideDetectServer
|
|
*/
|
|
function testDetectServer( $expected, $input, $description ) {
|
|
$oldServer = $_SERVER;
|
|
$_SERVER = $input;
|
|
$result = WebRequest::detectServer();
|
|
$_SERVER = $oldServer;
|
|
$this->assertEquals( $expected, $result, $description );
|
|
}
|
|
|
|
function provideDetectServer() {
|
|
return array(
|
|
array(
|
|
'http://x',
|
|
array(
|
|
'HTTP_HOST' => 'x'
|
|
),
|
|
'Host header'
|
|
),
|
|
array(
|
|
'https://x',
|
|
array(
|
|
'HTTP_HOST' => 'x',
|
|
'HTTPS' => 'on',
|
|
),
|
|
'Host header with secure'
|
|
),
|
|
array(
|
|
'http://x',
|
|
array(
|
|
'HTTP_HOST' => 'x',
|
|
'SERVER_PORT' => 80,
|
|
),
|
|
'Default SERVER_PORT',
|
|
),
|
|
array(
|
|
'http://x',
|
|
array(
|
|
'HTTP_HOST' => 'x',
|
|
'HTTPS' => 'off',
|
|
),
|
|
'Secure off'
|
|
),
|
|
array(
|
|
'http://y',
|
|
array(
|
|
'SERVER_NAME' => 'y',
|
|
),
|
|
'Server name'
|
|
),
|
|
array(
|
|
'http://x',
|
|
array(
|
|
'HTTP_HOST' => 'x',
|
|
'SERVER_NAME' => 'y',
|
|
),
|
|
'Host server name precedence'
|
|
),
|
|
array(
|
|
'http://[::1]:81',
|
|
array(
|
|
'HTTP_HOST' => '[::1]',
|
|
'SERVER_NAME' => '::1',
|
|
'SERVER_PORT' => '81',
|
|
),
|
|
'Apache bug 26005'
|
|
),
|
|
array(
|
|
'http://localhost',
|
|
array(
|
|
'SERVER_NAME' => '[2001'
|
|
),
|
|
'Kind of like lighttpd per commit message in MW r83847',
|
|
),
|
|
array(
|
|
'http://[2a01:e35:2eb4:1::2]:777',
|
|
array(
|
|
'SERVER_NAME' => '[2a01:e35:2eb4:1::2]:777'
|
|
),
|
|
'Possible lighttpd environment per bug 14977 comment 13',
|
|
),
|
|
);
|
|
}
|
|
}
|