1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
<?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',
),
);
}
}
|