X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FHttpFunctions.php;h=2ca5e1b71ffa331d8d1f0aec1b34cc1244fcc50e;hb=d821b71d1adb2ae6bb0fd16f221c6316978d506b;hp=b12f49f0b0f7a55aab1c94e1e51baaa577d28b04;hpb=ce4706e14c2c8f73f709f29b6766d3b7beb42a9f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index b12f49f0b0..2ca5e1b71f 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -124,47 +124,6 @@ class Http { return Http::request( 'POST', $url, $options, $caller ); } - /** - * Check if the URL can be served by localhost - * - * @param string $url Full url to check - * @return bool - */ - public static function isLocalURL( $url ) { - global $wgCommandLineMode, $wgLocalVirtualHosts; - - if ( $wgCommandLineMode ) { - return false; - } - - // Extract host part - $matches = []; - if ( preg_match( '!^http://([\w.-]+)[/:].*$!', $url, $matches ) ) { - $host = $matches[1]; - // Split up dotwise - $domainParts = explode( '.', $host ); - // Check if this domain or any superdomain is listed as a local virtual host - $domainParts = array_reverse( $domainParts ); - - $domain = ''; - $countParts = count( $domainParts ); - for ( $i = 0; $i < $countParts; $i++ ) { - $domainPart = $domainParts[$i]; - if ( $i == 0 ) { - $domain = $domainPart; - } else { - $domain = $domainPart . '.' . $domain; - } - - if ( in_array( $domain, $wgLocalVirtualHosts ) ) { - return true; - } - } - } - - return false; - } - /** * A standard user-agent we can use for external requests. * @return string @@ -194,7 +153,7 @@ class Http { } /** - * Gets the relevant proxy from $wgHTTPProxy/http_proxy (when set). + * Gets the relevant proxy from $wgHTTPProxy * * @return mixed The proxy address or an empty string if not set. */ @@ -205,11 +164,6 @@ class Http { return $wgHTTPProxy; } - $envHttpProxy = getenv( "http_proxy" ); - if ( $envHttpProxy ) { - return $envHttpProxy; - } - return ""; } } @@ -393,15 +347,56 @@ class MWHttpRequest { return; } - // Otherwise, fallback to $wgHTTPProxy/http_proxy (when set) if this is not a machine + // Otherwise, fallback to $wgHTTPProxy if this is not a machine // local URL and proxies are not disabled - if ( Http::isLocalURL( $this->url ) || $this->noProxy ) { + if ( self::isLocalURL( $this->url ) || $this->noProxy ) { $this->proxy = ''; } else { $this->proxy = Http::getProxy(); } } + /** + * Check if the URL can be served by localhost + * + * @param string $url Full url to check + * @return bool + */ + private static function isLocalURL( $url ) { + global $wgCommandLineMode, $wgLocalVirtualHosts; + + if ( $wgCommandLineMode ) { + return false; + } + + // Extract host part + $matches = []; + if ( preg_match( '!^https?://([\w.-]+)[/:].*$!', $url, $matches ) ) { + $host = $matches[1]; + // Split up dotwise + $domainParts = explode( '.', $host ); + // Check if this domain or any superdomain is listed as a local virtual host + $domainParts = array_reverse( $domainParts ); + + $domain = ''; + $countParts = count( $domainParts ); + for ( $i = 0; $i < $countParts; $i++ ) { + $domainPart = $domainParts[$i]; + if ( $i == 0 ) { + $domain = $domainPart; + } else { + $domain = $domainPart . '.' . $domain; + } + + if ( in_array( $domain, $wgLocalVirtualHosts ) ) { + return true; + } + } + } + + return false; + } + /** * Set the user agent * @param string $UA @@ -604,7 +599,7 @@ class MWHttpRequest { * Returns the value of the given response header. * * @param string $header - * @return string + * @return string|null */ public function getResponseHeader( $header ) { if ( !$this->respHeaders ) {