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
// 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