From: Brion Vibber Date: Tue, 17 Jul 2007 15:13:57 +0000 (+0000) Subject: A little more cleanup on the fallback (non-cURL) HttpFunctions fetch. X-Git-Tag: 1.31.0-rc.0~52050 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=e3dfb56b5220b206f0b9d98cfdd249c6d4d8c5cf;p=lhc%2Fweb%2Fwiklou.git A little more cleanup on the fallback (non-cURL) HttpFunctions fetch. Include a User-Agent header equivalent to the cURL one; this also is needed when fetching export pages from Wikipedia, as we currently block the default PHP user-agent string... --- diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index 249798a20b..bff9b3e6dc 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -59,14 +59,19 @@ class Http { } curl_close( $c ); } else { - # Otherwise use file_get_contents, or its compatibility function from GlobalFunctions.php + # Otherwise use file_get_contents... # This may take 3 minutes to time out, and doesn't have local fetch capabilities - $opts = array('http' => array( 'method' => $method ) ); + global $wgVersion; + $headers = array( "User-Agent: MediaWiki/$wgVersion" ); if( strcasecmp( $method, 'post' ) == 0 ) { // Required for HTTP 1.0 POSTs - $opts['http']['header'] = "Content-Length: 0"; + $headers[] = "Content-Length: 0"; } + $opts = array( + 'http' => array( + 'method' => $method, + 'header' => implode( "\r\n", $headers ) ) ); $ctx = stream_context_create($opts); $url_fopen = ini_set( 'allow_url_fopen', 1 );