@@ -80,7 +80,7 @@ function marshalUriFromSapi(array $server, array $headers) : Uri
80
80
* @return array Array of two items, host and port, in that order (can be
81
81
* passed to a list() operation).
82
82
*/
83
- $ marshalIpv6HostAndPort = function (array $ server , string $ host , ?int $ port ) : array {
83
+ $ marshalIpv6HostAndPort = function (array $ server , ?int $ port ) : array {
84
84
$ host = '[ ' . $ server ['SERVER_ADDR ' ] . '] ' ;
85
85
$ port = $ port ?: 80 ;
86
86
if ($ port . '] ' === substr ($ host , strrpos ($ host , ': ' ) + 1 )) {
@@ -93,8 +93,14 @@ function marshalUriFromSapi(array $server, array $headers) : Uri
93
93
94
94
static $ defaults = ['' , null ];
95
95
96
- if ($ getHeaderFromArray ('host ' , $ headers , false )) {
97
- return $ marshalHostAndPortFromHeader ($ getHeaderFromArray ('host ' , $ headers ));
96
+ $ forwardedHost = $ getHeaderFromArray ('x-forwarded-host ' , $ headers , false );
97
+ if ($ forwardedHost !== false ) {
98
+ return $ marshalHostAndPortFromHeader ($ forwardedHost );
99
+ }
100
+
101
+ $ host = $ getHeaderFromArray ('host ' , $ headers , false );
102
+ if ($ host !== false ) {
103
+ return $ marshalHostAndPortFromHeader ($ host );
98
104
}
99
105
100
106
if (! isset ($ server ['SERVER_NAME ' ])) {
@@ -112,7 +118,7 @@ function marshalUriFromSapi(array $server, array $headers) : Uri
112
118
113
119
// Misinterpreted IPv6-Address
114
120
// Reported for Safari on Windows
115
- return $ marshalIpv6HostAndPort ($ server , $ host , $ port );
121
+ return $ marshalIpv6HostAndPort ($ server , $ port );
116
122
};
117
123
118
124
/**
0 commit comments