Fix Bug 33384 - database drivers cannot be provided by extension
[lhc/web/wiklou.git] / includes / HttpFunctions.php
index b16b841..f8e7b37 100644 (file)
@@ -29,6 +29,8 @@ class Http {
         *    - 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() ) {
@@ -40,6 +42,9 @@ class Http {
                }
 
                $req = MWHttpRequest::factory( $url, $options );
+               if( isset( $options['userAgent'] ) ) {
+                       $req->setUserAgent( $options['userAgent'] );
+               }
                $status = $req->execute();
 
                if ( $status->isOK() ) {
@@ -586,6 +591,10 @@ class MWHttpRequest {
         * Relative values of the "Location" header are incorrect as stated in RFC, however they do happen and modern browsers support them.
         * This function loops backwards through all locations in order to build the proper absolute URI - Marooned at wikia-inc.com
         *
+        * Note that the multiple Location: headers are an artifact of CURL -- they
+        * shouldn't actually get returned this way. Rewrite this when bug 29232 is
+        * taken care of (high-level redirect handling rewrite).
+        *
         * @return string
         */
        public function getFinalUrl() {
@@ -857,7 +866,7 @@ class PhpHttpRequest extends MWHttpRequest {
                        # Check security of URL
                        $url = $this->getResponseHeader( "Location" );
 
-                       if ( !HTTP::isValidURI( $url ) ) {
+                       if ( !Http::isValidURI( $url ) ) {
                                wfDebug( __METHOD__ . ": insecure redirection\n" );
                                break;
                        }