- * @param $method string HTTP method. Usually GET/POST
- * @param $url string Full URL to act on
- * @param $opts options to pass to HttpRequest object
- * @returns mixed (bool)false on failure or a string on success
- */
- public static function request( $method, $url, $opts = array() ) {
- $opts['method'] = strtoupper( $method );
- if ( !array_key_exists( 'timeout', $opts ) ) {
- $opts['timeout'] = 'default';
- }
- $req = HttpRequest::factory( $url, $opts );
- $status = $req->doRequest();
+ *
+ * @param $method String: HTTP method. Usually GET/POST
+ * @param $url String: full URL to act on. If protocol-relative, will be expanded to an http:// URL
+ * @param $options Array: options to pass to MWHttpRequest object.
+ * Possible keys for the array:
+ * - timeout Timeout length in seconds
+ * - postData An array of key-value pairs or a url-encoded form data
+ * - proxy The proxy to use.
+ * Otherwise it will use $wgHTTPProxy (if set)
+ * Otherwise it will use the environment variable "http_proxy" (if set)
+ * - noProxy Don't use any proxy at all. Takes precedence over proxy value(s).
+ * - sslVerifyHost (curl only) Verify hostname against certificate
+ * - sslVerifyCert (curl only) Verify SSL certificate
+ * - caInfo (curl only) Provide CA information
+ * - maxRedirects Maximum number of redirects to follow (defaults to 5)
+ * - followRedirects Whether to follow redirects (defaults to false).
+ * Note: this should only be used when the target URL is trusted,
+ * to avoid attacks on intranet services accessible by HTTP.
+ * - userAgent A user agent, if you want to override the default
+ * MediaWiki/$wgVersion
+ * @return Mixed: (bool)false on failure or a string on success
+ */
+ public static function request( $method, $url, $options = array() ) {
+ wfDebug( "HTTP: $method: $url\n" );
+ $options['method'] = strtoupper( $method );
+
+ if ( !isset( $options['timeout'] ) ) {
+ $options['timeout'] = 'default';
+ }
+
+ $req = MWHttpRequest::factory( $url, $options );
+ $status = $req->execute();
+