Index: MediaWiki/branches/1.11/includes/HttpFunctions.php
===================================================================
--- MediaWiki/branches/1.11/includes/HttpFunctions.php	(revision 1280)
+++ MediaWiki/branches/1.11/includes/HttpFunctions.php	(revision 1281)
@@ -5,4 +5,12 @@
  */
 class Http {
+	static function get( $url, $timeout = 'default' ) {
+		return Http::request( "GET", $url, $timeout );
+	}
+
+	static function post( $url, $timeout = 'default' ) {
+		return Http::request( "POST", $url, $timeout );
+	}
+
 	/**
 	 * Get the contents of a file by HTTP
@@ -10,7 +18,8 @@
 	 * if $timeout is 'default', $wgHTTPTimeout is used
 	 */
-	static function get( $url, $timeout = 'default' ) {
+	static function request( $method, $url, $timeout = 'default' ) {
 		global $wgHTTPTimeout, $wgHTTPProxy, $wgVersion, $wgTitle;
 
+		wfDebug( __METHOD__ . ": $method $url\n" );
 		# Use curl if available
 		if ( function_exists( 'curl_init' ) ) {
@@ -27,4 +36,8 @@
 			curl_setopt( $c, CURLOPT_TIMEOUT, $timeout );
 			curl_setopt( $c, CURLOPT_USERAGENT, "MediaWiki/$wgVersion" );
+			if ( $method == 'POST' )
+				curl_setopt( $c, CURLOPT_POST, true );
+			else
+				curl_setopt( $c, CURLOPT_CUSTOMREQUEST, $method );
 
 			# Set the referer to $wgTitle, even in command-line mode
@@ -46,10 +59,27 @@
 				$text = false;
 			}
+			# Don't return truncated output
+			if ( curl_errno( $c ) != CURLE_OK ) {
+				$text = false;
+			}
 			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
+
+			global $wgVersion;
+			$headers = array( "User-Agent: MediaWiki/$wgVersion" );
+			if( strcasecmp( $method, 'post' ) == 0 ) {
+				// Required for HTTP 1.0 POSTs
+				$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 );
-			$text = file_get_contents( $url );
+			$text = file_get_contents( $url, false, $ctx );
 			ini_set( 'allow_url_fopen', $url_fopen );
 		}
@@ -89,3 +119,3 @@
 	}
 }
-?>
+
