r24200 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24199‎ | r24200 | r24201 >
Date:15:13, 17 July 2007
Author:brion
Status:old
Tags:
Comment:
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...
Modified paths:
  • /trunk/phase3/includes/HttpFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/HttpFunctions.php
@@ -59,14 +59,19 @@
6060 }
6161 curl_close( $c );
6262 } else {
63 - # Otherwise use file_get_contents, or its compatibility function from GlobalFunctions.php
 63+ # Otherwise use file_get_contents...
6464 # This may take 3 minutes to time out, and doesn't have local fetch capabilities
6565
66 - $opts = array('http' => array( 'method' => $method ) );
 66+ global $wgVersion;
 67+ $headers = array( "User-Agent: MediaWiki/$wgVersion" );
6768 if( strcasecmp( $method, 'post' ) == 0 ) {
6869 // Required for HTTP 1.0 POSTs
69 - $opts['http']['header'] = "Content-Length: 0";
 70+ $headers[] = "Content-Length: 0";
7071 }
 72+ $opts = array(
 73+ 'http' => array(
 74+ 'method' => $method,
 75+ 'header' => implode( "\r\n", $headers ) ) );
7176 $ctx = stream_context_create($opts);
7277
7378 $url_fopen = ini_set( 'allow_url_fopen', 1 );

Follow-up revisions

RevisionCommit summaryAuthorDate
r24215Merged revisions 24095-24212 via svnmerge from...david21:19, 17 July 2007

Status & tagging log